Skip to contentSkip to conversation

Cifs and Ceph: Uncache single no-data page in readpage()

PATCH In review Li Wang 2 participants 9 messages Nov 11, 2013

Subsystems (5)
lore
Share & tools
lore

Li Wang

author
#0 lore raw

cover Cifs and Ceph: Uncache single no-data page in readpage()

Currently, the page allocated into fscache in readpage() for Cifs and Ceph does not be uncached if no data read due to io error. This patch fixes this. fscache_readpages_cancel() is for this kind of job but taking list read * as input, so a new routine take page * as input is introduced.

Li Wang (7):
Fscache: Introduce new API fscache_readpage_cancel()
Fscache: Implement uncaching single no-data page
Ceph: Introduce routine for uncaching single no-data page
Ceph: Uncaching no-data page in readpage()
Cifs: Introduce routine for uncaching single no-data page
Cifs: Implement uncaching single no-data page
Cifs: Uncaching no-data page in readpage()

 fs/ceph/addr.c          |    1 +
 fs/ceph/cache.h         |   13 +++++++++++++
 fs/cifs/file.c          |    4 +++-
 fs/cifs/fscache.c       |    7 +++++++
 fs/cifs/fscache.h       |   13 +++++++++++++
 fs/fscache/page.c       |    8 ++++++++
 include/linux/fscache.h |   11 +++++++++++
 7 files changed, 56 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/7 Fscache: Introduce new API fscache_readpage_cancel()

Introduce a new API fscache_readpage_cancel() for uncaching one single no-data page from fscache.

---
 include/linux/fscache.h |   11 +++++++++++
 1 file changed, 11 insertions(+)
include/linux/fscache.h +11 -0
index 115bb81..f1ed21f 100644
@@ -245,6 +245,8 @@ extern bool __fscache_maybe_release_page(struct fscache_cookie *, struct page *,
 					 gfp_t);
 extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *,
 					      struct inode *);
+extern void __fscache_readpage_cancel(struct fscache_cookie *cookie,
+				      struct page *page);
 extern void __fscache_readpages_cancel(struct fscache_cookie *cookie,
 				       struct list_head *pages);
 extern void __fscache_disable_cookie(struct fscache_cookie *, bool);
@@ -633,6 +635,15 @@ int fscache_alloc_page(struct fscache_cookie *cookie,
 		return -ENOBUFS;
 }
 
+static inline
+void fscache_readpage_cancel(struct fscache_cookie *cookie,
+			     struct page *page)
+{
+	if (fscache_cookie_valid(cookie))
+		__fscache_readpage_cancel(cookie, page);
+}
+
+
 /**
  * fscache_readpages_cancel - Cancel read/alloc on pages
  * @cookie: The cookie representing the inode's cache object.
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/7 Fscache: Implement uncaching single no-data page

In reply to Li Wang

Similar to the routine for multiple pages except that it takes page * as input rather than list head *.

---
 fs/fscache/page.c |    8 ++++++++
 1 file changed, 8 insertions(+)
fs/fscache/page.c +8 -0
index 7f5c658..0c69f72 100644
@@ -721,6 +721,14 @@ nobufs:
 }
 EXPORT_SYMBOL(__fscache_alloc_page);
 
+void __fscache_readpage_cancel(struct fscache_cookie *cookie,
+			       struct page *page)
+{
+	if (PageFsCache(page))
+		__fscache_uncache_page(cookie, page);
+}
+EXPORT_SYMBOL(__fscache_readpage_cancel);
+
 /*
  * Unmark pages allocate in the readahead code path (via:
  * fscache_readpages_or_alloc) after delegating to the base filesystem
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH 3/7 Ceph: Introduce routine for uncaching single no-data page

In reply to Li Wang

Introduce a routine for uncaching single no-data page, typically in readpage().

---
 fs/ceph/cache.h |   13 +++++++++++++
 1 file changed, 13 insertions(+)
fs/ceph/cache.h +13 -0
index ba94940..eb0ec76 100644
@@ -67,6 +67,14 @@ static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp)
 	return fscache_maybe_release_page(ci->fscache, page, gfp);
 }
 
+
+static inline void cpeh_fscache_readpage_cancel(struct inode *inode,
+						struct page *page)
+{
+	struct ceph_inode_info *ci = ceph_inode(inode);
+	return fscache_readpage_cancel(ci->fscache, page);
+}
+
 static inline void ceph_fscache_readpages_cancel(struct inode *inode,
 						 struct list_head *pages)
 {
@@ -145,6 +153,11 @@ static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp)
 	return 1;
 }
 
+static inline void ceph_fscache_readpage_cancel(struct inode *inode,
+						struct page *page)
+{
+}
+
 static inline void ceph_fscache_readpages_cancel(struct inode *inode,
 						 struct list_head *pages)
 {
Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH 4/7 Ceph: Uncaching no-data page in readpage()

In reply to Li Wang

Currently, if one page allocated into fscache in readpage(), however, with no-data read, it is not uncached. This patch fixes this.

---
 fs/ceph/addr.c |    1 +
 1 file changed, 1 insertion(+)
fs/ceph/addr.c +1 -0
index 6df8bd4..be5f4b6 100644
@@ -209,6 +209,7 @@ static int readpage_nounlock(struct file *filp, struct page *page)
 		err = 0;
 	if (err < 0) {
 		SetPageError(page);
+		ceph_fscache_readpage_cancel(inode, page);
 		goto out;
 	} else if (err < PAGE_CACHE_SIZE) {
 		/* zero fill remainder of page */
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH 5/7 Cifs: Introduce routine for uncaching single no-data page

In reply to Li Wang

Introduce a routine for uncaching single no-data page, typically in readpage().

---
 fs/cifs/fscache.h |   13 +++++++++++++
 1 file changed, 13 insertions(+)
fs/cifs/fscache.h +13 -0
index 24794b6..c712f42 100644
@@ -54,6 +54,7 @@ extern int __cifs_readpages_from_fscache(struct inode *,
 					 struct address_space *,
 					 struct list_head *,
 					 unsigned *);
+extern void __cifs_fscache_readpage_cancel(struct inode *, struct page *);
 extern void __cifs_fscache_readpages_cancel(struct inode *, struct list_head *);
 
 extern void __cifs_readpage_to_fscache(struct inode *, struct page *);
@@ -92,6 +93,13 @@ static inline void cifs_readpage_to_fscache(struct inode *inode,
 		__cifs_readpage_to_fscache(inode, page);
 }
 
+static inline void cifs_fscache_readpage_cancel(struct inode *inode,
+						struct page *page)
+{
+	if (CIFS_I(inode)->fscache)
+		return __cifs_fscache_readpage_cancel(inode, page);
+}
+
 static inline void cifs_fscache_readpages_cancel(struct inode *inode,
 						 struct list_head *pages)
 {
@@ -139,6 +147,11 @@ static inline int cifs_readpages_from_fscache(struct inode *inode,
 static inline void cifs_readpage_to_fscache(struct inode *inode,
 			struct page *page) {}
 
+static inline void cifs_fscache_readpage_cancel(struct inode *inode,
+						struct page *page)
+{
+}
+
 static inline void cifs_fscache_readpages_cancel(struct inode *inode,
 						 struct list_head *pages)
 {
Signature · 1 line
1.7.9.5
author
#6 lore raw

PATCH 6/7 Cifs: Implement uncaching single no-data page

In reply to Li Wang

Implement the routine for uncaching single no-data page, typically in readpage().

---
 fs/cifs/fscache.c |    7 +++++++
 1 file changed, 7 insertions(+)
fs/cifs/fscache.c +7 -0
index 8d4b7bc..168f184 100644
@@ -223,6 +223,13 @@ void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)
 		fscache_uncache_page(CIFS_I(inode)->fscache, page);
 }
 
+void __cifs_fscache_readpage_cancel(struct inode *inode, struct page *page)
+{
+        cifs_dbg(FYI, "%s: (fsc: %p, i: %p)\n",
+                 __func__, CIFS_I(inode)->fscache, inode);
+        fscache_readpage_cancel(CIFS_I(inode)->fscache, page);
+}
+
 void __cifs_fscache_readpages_cancel(struct inode *inode, struct list_head *pages)
 {
 	cifs_dbg(FYI, "%s: (fsc: %p, i: %p)\n",
Signature · 1 line
1.7.9.5
author
#7 lore raw

PATCH 7/7 Cifs: Uncaching no-data page in readpage()

In reply to Li Wang

Currently, if one page allocated into fscache in readpage(), however, with no-data read, it is not uncached. This patch fixes this.

---
 fs/cifs/file.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/file.c +3 -1
index 7ddddf2..153bc58 100644
@@ -3406,8 +3406,10 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
 
 	rc = cifs_read(file, read_data, PAGE_CACHE_SIZE, poffset);
 
-	if (rc < 0)
+	if (rc < 0) {
+		cifs_fscache_readpage_cancel(file_inode(file), page);
 		goto io_error;
+	}
 	else
 		cifs_dbg(FYI, "Bytes read %d\n", rc);
 
Signature · 1 line
1.7.9.5
#8 lore raw
In reply to Li Wang

Li,

I recommend you CC David Howells who maintains FSCache directly on your emails.

Thanks,
- Milosz

Quoted 27 lines · Li Wang

Currently, the page allocated into fscache in readpage() for Cifs and Ceph does not be uncached if no data read due to io error. This patch fixes this. fscache_readpages_cancel() is for this kind of job but taking list read * as input, so a new routine take page * as input is introduced.

Li Wang (7):
Fscache: Introduce new API fscache_readpage_cancel()
Fscache: Implement uncaching single no-data page
Ceph: Introduce routine for uncaching single no-data page
Ceph: Uncaching no-data page in readpage()
Cifs: Introduce routine for uncaching single no-data page
Cifs: Implement uncaching single no-data page
Cifs: Uncaching no-data page in readpage()

 fs/ceph/addr.c          |    1 +
 fs/ceph/cache.h         |   13 +++++++++++++
 fs/cifs/file.c          |    4 +++-
 fs/cifs/fscache.c       |    7 +++++++
 fs/cifs/fscache.h       |   13 +++++++++++++
 fs/fscache/page.c       |    8 ++++++++
 include/linux/fscache.h |   11 +++++++++++
 7 files changed, 56 insertions(+), 1 deletion(-)

--
1.7.9.5

Signature · 7 lines
Milosz Tanski
CTO
10 East 53rd Street, 37th floor
New York, NY 10022

p: 646-253-9055
e: [email protected]