aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cachefiles/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cachefiles/interface.c')
-rw-r--r--fs/cachefiles/interface.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c
index dd7f852746cb..8e67abf05985 100644
--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -404,12 +404,26 @@ static int cachefiles_attr_changed(struct fscache_object *_object)
404 if (oi_size == ni_size) 404 if (oi_size == ni_size)
405 return 0; 405 return 0;
406 406
407 newattrs.ia_size = ni_size;
408 newattrs.ia_valid = ATTR_SIZE;
409
410 cachefiles_begin_secure(cache, &saved_cred); 407 cachefiles_begin_secure(cache, &saved_cred);
411 mutex_lock(&object->backer->d_inode->i_mutex); 408 mutex_lock(&object->backer->d_inode->i_mutex);
409
410 /* if there's an extension to a partial page at the end of the backing
411 * file, we need to discard the partial page so that we pick up new
412 * data after it */
413 if (oi_size & ~PAGE_MASK && ni_size > oi_size) {
414 _debug("discard tail %llx", oi_size);
415 newattrs.ia_valid = ATTR_SIZE;
416 newattrs.ia_size = oi_size & PAGE_MASK;
417 ret = notify_change(object->backer, &newattrs);
418 if (ret < 0)
419 goto truncate_failed;
420 }
421
422 newattrs.ia_valid = ATTR_SIZE;
423 newattrs.ia_size = ni_size;
412 ret = notify_change(object->backer, &newattrs); 424 ret = notify_change(object->backer, &newattrs);
425
426truncate_failed:
413 mutex_unlock(&object->backer->d_inode->i_mutex); 427 mutex_unlock(&object->backer->d_inode->i_mutex);
414 cachefiles_end_secure(cache, saved_cred); 428 cachefiles_end_secure(cache, saved_cred);
415 429