[PATCH 30/19] CacheFiles: Fix the allocate_page() op

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix cachefiles_allocate_page() to mark the specified page as being retained if
it returns successfully.

Also fix the header comment on that function (it doesn't read data from the
disk).

Signed-Off-By: David Howells <[email protected]>
---

 fs/cachefiles/cf-interface.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/fs/cachefiles/cf-interface.c b/fs/cachefiles/cf-interface.c
index e96e63a..a08831b 100644
--- a/fs/cachefiles/cf-interface.c
+++ b/fs/cachefiles/cf-interface.c
@@ -1108,7 +1108,7 @@ static int cachefiles_read_or_alloc_page
 }
 
 /*
- * read a page from the cache or allocate a block in which to store it
+ * allocate a block in the cache in which to store a page
  * - cache withdrawal is prevented by the caller
  * - returns -EINTR if interrupted
  * - returns -ENOMEM if ran out of memory
@@ -1124,6 +1124,9 @@ static int cachefiles_allocate_page(stru
 {
 	struct cachefiles_object *object;
 	struct cachefiles_cache *cache;
+	struct fscache_cookie *cookie;
+	struct pagevec pagevec;
+	int ret;
 
 	object = container_of(_object, struct cachefiles_object, fscache);
 	cache = container_of(object->fscache.cache,
@@ -1131,7 +1134,19 @@ static int cachefiles_allocate_page(stru
 
 	_enter("%p,{%lx},,,", object, page->index);
 
-	return cachefiles_has_space(cache, 0, 1);
+	ret = cachefiles_has_space(cache, 0, 1);
+	if (ret == 0) {
+		pagevec_init(&pagevec, 0);
+		pagevec_add(&pagevec, page);
+		cookie = object->fscache.cookie;
+		cookie->def->mark_pages_cached(cookie->netfs_data,
+					       page->mapping, &pagevec);
+	} else {
+		ret = -ENOBUFS;
+	}
+
+	_leave(" = %d", ret);
+	return ret;
 }
 
 /*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux