Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85f2d6b4 authored by Suresh Jayaraman's avatar Suresh Jayaraman Committed by Steve French
Browse files

cifs: FS-Cache page management



Takes care of invalidation and release of FS-Cache marked pages and also
invalidation of the FsCache page flag when the inode is removed.

Signed-off-by: default avatarSuresh Jayaraman <sjayaraman@suse.de>
Acked-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 9451a9a5
Loading
Loading
Loading
Loading
+31 −0
Original line number Original line Diff line number Diff line
@@ -290,6 +290,36 @@ fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
	return FSCACHE_CHECKAUX_OKAY;
	return FSCACHE_CHECKAUX_OKAY;
}
}


static void cifs_fscache_inode_now_uncached(void *cookie_netfs_data)
{
	struct cifsInodeInfo *cifsi = cookie_netfs_data;
	struct pagevec pvec;
	pgoff_t first;
	int loop, nr_pages;

	pagevec_init(&pvec, 0);
	first = 0;

	cFYI(1, "cifs inode 0x%p now uncached", cifsi);

	for (;;) {
		nr_pages = pagevec_lookup(&pvec,
					  cifsi->vfs_inode.i_mapping, first,
					  PAGEVEC_SIZE - pagevec_count(&pvec));
		if (!nr_pages)
			break;

		for (loop = 0; loop < nr_pages; loop++)
			ClearPageFsCache(pvec.pages[loop]);

		first = pvec.pages[nr_pages - 1]->index + 1;

		pvec.nr = nr_pages;
		pagevec_release(&pvec);
		cond_resched();
	}
}

const struct fscache_cookie_def cifs_fscache_inode_object_def = {
const struct fscache_cookie_def cifs_fscache_inode_object_def = {
	.name		= "CIFS.uniqueid",
	.name		= "CIFS.uniqueid",
	.type		= FSCACHE_COOKIE_TYPE_DATAFILE,
	.type		= FSCACHE_COOKIE_TYPE_DATAFILE,
@@ -297,4 +327,5 @@ const struct fscache_cookie_def cifs_fscache_inode_object_def = {
	.get_attr	= cifs_fscache_inode_get_attr,
	.get_attr	= cifs_fscache_inode_get_attr,
	.get_aux	= cifs_fscache_inode_get_aux,
	.get_aux	= cifs_fscache_inode_get_aux,
	.check_aux	= cifs_fscache_inode_check_aux,
	.check_aux	= cifs_fscache_inode_check_aux,
	.now_uncached	= cifs_fscache_inode_now_uncached,
};
};
+20 −0
Original line number Original line Diff line number Diff line
@@ -2267,6 +2267,22 @@ static int cifs_write_begin(struct file *file, struct address_space *mapping,
	return rc;
	return rc;
}
}


static int cifs_release_page(struct page *page, gfp_t gfp)
{
	if (PagePrivate(page))
		return 0;

	return cifs_fscache_release_page(page, gfp);
}

static void cifs_invalidate_page(struct page *page, unsigned long offset)
{
	struct cifsInodeInfo *cifsi = CIFS_I(page->mapping->host);

	if (offset == 0)
		cifs_fscache_invalidate_page(page, &cifsi->vfs_inode);
}

static void
static void
cifs_oplock_break(struct slow_work *work)
cifs_oplock_break(struct slow_work *work)
{
{
@@ -2340,6 +2356,8 @@ const struct address_space_operations cifs_addr_ops = {
	.write_begin = cifs_write_begin,
	.write_begin = cifs_write_begin,
	.write_end = cifs_write_end,
	.write_end = cifs_write_end,
	.set_page_dirty = __set_page_dirty_nobuffers,
	.set_page_dirty = __set_page_dirty_nobuffers,
	.releasepage = cifs_release_page,
	.invalidatepage = cifs_invalidate_page,
	/* .sync_page = cifs_sync_page, */
	/* .sync_page = cifs_sync_page, */
	/* .direct_IO = */
	/* .direct_IO = */
};
};
@@ -2356,6 +2374,8 @@ const struct address_space_operations cifs_addr_ops_smallbuf = {
	.write_begin = cifs_write_begin,
	.write_begin = cifs_write_begin,
	.write_end = cifs_write_end,
	.write_end = cifs_write_end,
	.set_page_dirty = __set_page_dirty_nobuffers,
	.set_page_dirty = __set_page_dirty_nobuffers,
	.releasepage = cifs_release_page,
	.invalidatepage = cifs_invalidate_page,
	/* .sync_page = cifs_sync_page, */
	/* .sync_page = cifs_sync_page, */
	/* .direct_IO = */
	/* .direct_IO = */
};
};
+26 −0
Original line number Original line Diff line number Diff line
@@ -124,3 +124,29 @@ void cifs_fscache_reset_inode_cookie(struct inode *inode)
				cifsi->fscache, old);
				cifsi->fscache, old);
	}
	}
}
}

int cifs_fscache_release_page(struct page *page, gfp_t gfp)
{
	if (PageFsCache(page)) {
		struct inode *inode = page->mapping->host;
		struct cifsInodeInfo *cifsi = CIFS_I(inode);

		cFYI(1, "CIFS: fscache release page (0x%p/0x%p)",
				page, cifsi->fscache);
		if (!fscache_maybe_release_page(cifsi->fscache, page, gfp))
			return 0;
	}

	return 1;
}

void __cifs_fscache_invalidate_page(struct page *page, struct inode *inode)
{
	struct cifsInodeInfo *cifsi = CIFS_I(inode);
	struct fscache_cookie *cookie = cifsi->fscache;

	cFYI(1, "CIFS: fscache invalidatepage (0x%p/0x%p)", page, cookie);
	fscache_wait_on_page_write(cookie, page);
	fscache_uncache_page(cookie, page);
}
+16 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,16 @@ extern void cifs_fscache_release_inode_cookie(struct inode *);
extern void cifs_fscache_set_inode_cookie(struct inode *, struct file *);
extern void cifs_fscache_set_inode_cookie(struct inode *, struct file *);
extern void cifs_fscache_reset_inode_cookie(struct inode *);
extern void cifs_fscache_reset_inode_cookie(struct inode *);


extern void __cifs_fscache_invalidate_page(struct page *, struct inode *);
extern int cifs_fscache_release_page(struct page *page, gfp_t gfp);

static inline void cifs_fscache_invalidate_page(struct page *page,
					       struct inode *inode)
{
	if (PageFsCache(page))
		__cifs_fscache_invalidate_page(page, inode);
}

#else /* CONFIG_CIFS_FSCACHE */
#else /* CONFIG_CIFS_FSCACHE */
static inline int cifs_fscache_register(void) { return 0; }
static inline int cifs_fscache_register(void) { return 0; }
static inline void cifs_fscache_unregister(void) {}
static inline void cifs_fscache_unregister(void) {}
@@ -64,7 +74,13 @@ static inline void cifs_fscache_release_inode_cookie(struct inode *inode) {}
static inline void cifs_fscache_set_inode_cookie(struct inode *inode,
static inline void cifs_fscache_set_inode_cookie(struct inode *inode,
						 struct file *filp) {}
						 struct file *filp) {}
static inline void cifs_fscache_reset_inode_cookie(struct inode *inode) {}
static inline void cifs_fscache_reset_inode_cookie(struct inode *inode) {}
static inline void cifs_fscache_release_page(struct page *page, gfp_t gfp)
{
	return 1; /* May release page */
}


static inline int cifs_fscache_invalidate_page(struct page *page,
			struct inode *) {}


#endif /* CONFIG_CIFS_FSCACHE */
#endif /* CONFIG_CIFS_FSCACHE */