1 From: Suresh Jayaraman <sjayaraman@suse.de>
2 Subject: [RFC][PATCH 07/10] cifs: FS-Cache page management
3 Date: Tue, 22 Jun 2010 20:53:48 +0530
5 Message-ID: <1277220228-3635-1-git-send-email-sjayaraman@suse.de>
7 Cc: linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
8 linux-kernel@vger.kernel.org, David Howells <dhowells@redhat.com>
9 To: Steve French <smfrench@gmail.com>
10 X-From: linux-kernel-owner@vger.kernel.org Tue Jun 22 17:44:27 2010
11 Return-path: <linux-kernel-owner@vger.kernel.org>
12 Envelope-to: glk-linux-kernel-3@lo.gmane.org
13 Received: from vger.kernel.org ([209.132.180.67])
14 by lo.gmane.org with esmtp (Exim 4.69)
15 (envelope-from <linux-kernel-owner@vger.kernel.org>)
17 for glk-linux-kernel-3@lo.gmane.org; Tue, 22 Jun 2010 17:44:27 +0200
18 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
19 id S1754757Ab0FVPoS (ORCPT <rfc822;glk-linux-kernel-3@m.gmane.org>);
20 Tue, 22 Jun 2010 11:44:18 -0400
21 Received: from victor.provo.novell.com ([137.65.250.26]:54214 "EHLO
22 victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
23 with ESMTP id S1752542Ab0FVPoB (ORCPT
24 <rfc822;groupwise-SJayaraman@novell.com:0:0>);
25 Tue, 22 Jun 2010 11:44:01 -0400
26 Received: from localhost (prv-ext-foundry1int.gns.novell.com [137.65.251.240])
27 by victor.provo.novell.com with ESMTP; Tue, 22 Jun 2010 09:23:50 -0600
28 X-Mailer: git-send-email 1.6.4.2
30 Sender: linux-kernel-owner@vger.kernel.org
32 List-ID: <linux-kernel.vger.kernel.org>
33 X-Mailing-List: linux-kernel@vger.kernel.org
34 Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1001761>
36 Takes care of invalidation and release of FS-Cache marked pages and also
37 invalidation of the FsCache page flag when the inode is removed.
39 Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
41 fs/cifs/cache.c | 31 +++++++++++++++++++++++++++++++
42 fs/cifs/file.c | 20 ++++++++++++++++++++
43 fs/cifs/fscache.c | 26 ++++++++++++++++++++++++++
44 fs/cifs/fscache.h | 16 ++++++++++++++++
45 4 files changed, 93 insertions(+), 0 deletions(-)
47 diff --git a/fs/cifs/cache.c b/fs/cifs/cache.c
48 index b205424..3a733c1 100644
51 @@ -210,6 +210,36 @@ fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
52 return FSCACHE_CHECKAUX_OKAY;
55 +static void cifs_fscache_inode_now_uncached(void *cookie_netfs_data)
57 + struct cifsInodeInfo *cifsi = cookie_netfs_data;
58 + struct pagevec pvec;
62 + pagevec_init(&pvec, 0);
65 + cFYI(1, "cifs inode 0x%p now uncached\n", cifsi);
68 + nr_pages = pagevec_lookup(&pvec,
69 + cifsi->vfs_inode.i_mapping, first,
70 + PAGEVEC_SIZE - pagevec_count(&pvec));
74 + for (loop = 0; loop < nr_pages; loop++)
75 + ClearPageFsCache(pvec.pages[loop]);
77 + first = pvec.pages[nr_pages - 1]->index + 1;
80 + pagevec_release(&pvec);
85 const struct fscache_cookie_def cifs_fscache_inode_object_def = {
86 .name = "CIFS.uniqueid",
87 .type = FSCACHE_COOKIE_TYPE_DATAFILE,
88 @@ -217,4 +247,5 @@ const struct fscache_cookie_def cifs_fscache_inode_object_def = {
89 .get_attr = cifs_fscache_inode_get_attr,
90 .get_aux = cifs_fscache_inode_get_aux,
91 .check_aux = cifs_fscache_inode_check_aux,
92 + .now_uncached = cifs_fscache_inode_now_uncached,
94 diff --git a/fs/cifs/file.c b/fs/cifs/file.c
95 index 55ecb55..786ec04 100644
98 @@ -2271,6 +2271,22 @@ out:
102 +static int cifs_release_page(struct page *page, gfp_t gfp)
104 + if (PagePrivate(page))
107 + return cifs_fscache_release_page(page, gfp);
110 +static void cifs_invalidate_page(struct page *page, unsigned long offset)
112 + struct cifsInodeInfo *cifsi = CIFS_I(page->mapping->host);
115 + cifs_fscache_invalidate_page(page, &cifsi->vfs_inode);
119 cifs_oplock_break(struct slow_work *work)
121 @@ -2344,6 +2360,8 @@ const struct address_space_operations cifs_addr_ops = {
122 .write_begin = cifs_write_begin,
123 .write_end = cifs_write_end,
124 .set_page_dirty = __set_page_dirty_nobuffers,
125 + .releasepage = cifs_release_page,
126 + .invalidatepage = cifs_invalidate_page,
127 /* .sync_page = cifs_sync_page, */
130 @@ -2360,6 +2378,8 @@ const struct address_space_operations cifs_addr_ops_smallbuf = {
131 .write_begin = cifs_write_begin,
132 .write_end = cifs_write_end,
133 .set_page_dirty = __set_page_dirty_nobuffers,
134 + .releasepage = cifs_release_page,
135 + .invalidatepage = cifs_invalidate_page,
136 /* .sync_page = cifs_sync_page, */
139 diff --git a/fs/cifs/fscache.c b/fs/cifs/fscache.c
140 index ddfd355..c09d3b8 100644
141 --- a/fs/cifs/fscache.c
142 +++ b/fs/cifs/fscache.c
143 @@ -130,3 +130,29 @@ void cifs_fscache_reset_inode_cookie(struct inode *inode)
147 +int cifs_fscache_release_page(struct page *page, gfp_t gfp)
149 + if (PageFsCache(page)) {
150 + struct inode *inode = page->mapping->host;
151 + struct cifsInodeInfo *cifsi = CIFS_I(inode);
153 + cFYI(1, "CIFS: fscache release page (0x%p/0x%p)\n",
154 + cifsi->fscache, page);
155 + if (!fscache_maybe_release_page(cifsi->fscache, page, gfp))
162 +void __cifs_fscache_invalidate_page(struct page *page, struct inode *inode)
164 + struct cifsInodeInfo *cifsi = CIFS_I(inode);
165 + struct fscache_cookie *cookie = cifsi->fscache;
167 + cFYI(1, "CIFS: fscache invalidatepage (0x%p/0x%p/0x%p)\n",
168 + cookie, page, cifsi);
169 + fscache_wait_on_page_write(cookie, page);
170 + fscache_uncache_page(cookie, page);
173 diff --git a/fs/cifs/fscache.h b/fs/cifs/fscache.h
174 index 836bb02..127cb0a 100644
175 --- a/fs/cifs/fscache.h
176 +++ b/fs/cifs/fscache.h
177 @@ -47,6 +47,16 @@ extern void cifs_fscache_release_inode_cookie(struct inode *);
178 extern void cifs_fscache_set_inode_cookie(struct inode *, struct file *);
179 extern void cifs_fscache_reset_inode_cookie(struct inode *);
181 +extern void __cifs_fscache_invalidate_page(struct page *, struct inode *);
182 +extern int cifs_fscache_release_page(struct page *page, gfp_t gfp);
184 +static inline void cifs_fscache_invalidate_page(struct page *page,
185 + struct inode *inode)
187 + if (PageFsCache(page))
188 + __cifs_fscache_invalidate_page(page, inode);
191 #else /* CONFIG_CIFS_FSCACHE */
192 static inline int cifs_fscache_register(void) { return 0; }
193 static inline void cifs_fscache_unregister(void) {}
194 @@ -63,7 +73,13 @@ static inline void cifs_fscache_release_inode_cookie(struct inode *inode) {}
195 static inline void cifs_fscache_set_inode_cookie(struct inode *inode,
196 struct file *filp) {}
197 static inline void cifs_fscache_reset_inode_cookie(struct inode *inode) {}
198 +static inline void cifs_fscache_release_page(struct page *page, gfp_t gfp)
200 + return 1; /* May release page */
203 +static inline int cifs_fscache_invalidate_page(struct page *page,
206 #endif /* CONFIG_CIFS_FSCACHE */