Skip to contentSkip to conversation

cachefiles: fix calculation of the number of needed blocks

PATCH New Jingbo Xu 1 participant 1 message Feb 14, 2023 Cachefiles: fs-cache backend for caching on mounted filesystems

lore
Share & tools
lore

Jingbo Xu

author
#0 lore raw

PATCH 1/1 cachefiles: fix calculation of the number of needed blocks

The number of needed blocks shall be measured with block size rather than PAGE_SIZE.

Fixes 047487c947e8 ("cachefiles: Implement the I/O routines")
---
 fs/cachefiles/io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cachefiles/io.c +2 -2
index 175a25fcade8..09605891cf85 100644
@@ -565,7 +565,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 	 * space, we need to see if it's fully allocated.  If it's not, we may
 	 * want to cull it.
 	 */
-	if (cachefiles_has_space(cache, 0, *_len / PAGE_SIZE,
+	if (cachefiles_has_space(cache, 0, *_len >> cache->bshift,
 				 cachefiles_has_space_check) == 0)
 		return 0; /* Enough space to simply overwrite the whole block */
 
@@ -597,7 +597,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
 	return ret;
 
 check_space:
-	return cachefiles_has_space(cache, 0, *_len / PAGE_SIZE,
+	return cachefiles_has_space(cache, 0, *_len >> cache->bshift,
 				    cachefiles_has_space_for_write);
 }
 
Signature · 1 line
2.19.1.6.gb485710b