foo
diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c index 1e784541..4446723 100644 --- a/fs/cachefiles/bind.c +++ b/fs/cachefiles/bind.c
@@ -9,7 +9,6 @@ * 2 of the Licence, or (at your option) any later version. */ -#define __KDEBUG #include <linux/module.h> #include <linux/init.h> #include <linux/sched.h>
diff --git a/fs/cachefiles/cull_index.c b/fs/cachefiles/cull_index.c index 7a01796..52d0592 100644 --- a/fs/cachefiles/cull_index.c +++ b/fs/cachefiles/cull_index.c
@@ -9,7 +9,6 @@ * 2 of the Licence, or (at your option) any later version. */ -#define __KDEBUG #include <linux/module.h> #include <linux/init.h> #include <linux/sched.h> @@ -621,15 +620,14 @@ old_fs = get_fs(); set_fs(KERNEL_DS); _debug("CLEAR index 1 @ %llx", pos); - ret = cache->cull_index->f_op->write( - cache->cull_index, - (const void __user *) empty_zero_page, 2, &pos); + ret = vfs_write(cache->cull_index, + (const void __user *)empty_zero_page, 2, &pos); if (ret != 2) goto ioerror; - ret = cache->cull_atimes->f_op->write( - cache->cull_atimes, - (const void __user *) empty_zero_page, sizeof(__le32), &apos); + ret = vfs_write(cache->cull_atimes, + (const void __user *)empty_zero_page, sizeof(__le32), + &apos); if (ret != sizeof(__le32)) goto ioerror; @@ -720,9 +718,8 @@ /* read the contents of the slot so that we can check it */ tmppos = pos; - read = cache->cull_index->f_op->read( - cache->cull_index, (void * __user) entry, - cache->cx_entsize, &tmppos); + read = vfs_read(cache->cull_index, (void * __user) entry, + cache->cx_entsize, &tmppos); if (read != cache->cx_entsize) { cachefiles_io_error(cache, "Cull index slot %d fill check error: %ld", @@ -746,9 +743,8 @@ * - we just decide not to care if the slot is already occupied */ tmppos = pos; - written = cache->cull_index->f_op->write( - cache->cull_index, (const void * __user) entry, - cache->cx_entsize, &tmppos); + written = vfs_write(cache->cull_index, (const void * __user) entry, + cache->cx_entsize, &tmppos); if (written != cache->cx_entsize) { cachefiles_io_error( @@ -831,8 +827,8 @@ old_fs = get_fs(); set_fs(KERNEL_DS); - ret = cache->cull_atimes->f_op->write( - cache->cull_atimes, (const void __user *) &buffer, 4, &pos); + ret = vfs_write(cache->cull_atimes, + (const void __user *) &buffer, 4, &pos); set_fs(old_fs); if (ret != 4) { @@ -888,9 +884,8 @@ old_fs = get_fs(); set_fs(KERNEL_DS); - read = cache->cull_index->f_op->read(cache->cull_index, - (void * __user) entry, - cache->cx_entsize, &pos); + read = vfs_read(cache->cull_index, + (void * __user) entry, cache->cx_entsize, &pos); set_fs(old_fs); if (read != cache->cx_entsize) { @@ -904,7 +899,7 @@ /* check that the slot is occupied */ if (entry->type == 0) { kfree(buffer); - kleave(" = -ESTALE [unoccupied]"); + _leave(" = -ESTALE [unoccupied]"); return -ESTALE; } @@ -916,7 +911,7 @@ if (IS_ERR(dentry)) { ret = PTR_ERR(dentry); if (ret == -ESTALE) { - kleave(" = -ESTALE [unresolvable]"); + _leave(" = -ESTALE [unresolvable]"); return -ESTALE; } pr_err("Cannot decode cull slot %d FH: %d", slot, ret); @@ -938,7 +933,7 @@ *_dir = dir; *_object = dentry; - kleave(" = 0"); + _leave(" = 0"); return 0; } @@ -984,9 +979,8 @@ /* read the contents of the slot so that we can check it */ old_fs = get_fs(); set_fs(KERNEL_DS); - read = cache->cull_index->f_op->read( - cache->cull_index, (void * __user) entry, - cache->cx_entsize, &pos); + read = vfs_read(cache->cull_index, (void * __user) entry, + cache->cx_entsize, &pos); set_fs(old_fs); if (read != cache->cx_entsize) {
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index 89fcb44..00444d0 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c
@@ -179,11 +179,9 @@ //_enter(",,%zu,", buflen); - if (!test_bit(CACHEFILES_READY, &cache->flags)) - return 0; - /* check how much space the cache has */ - cachefiles_has_space(cache, 0, 0); + if (test_bit(CACHEFILES_READY, &cache->flags)) + cachefiles_has_space(cache, 0, 0); /* summarise */ clear_bit(CACHEFILES_STATE_CHANGED, &cache->flags); @@ -868,9 +866,10 @@ return -EINVAL; if (scanrc) { - pr_err("cachefilesd daemon fsck failed with rc=%ld\n", scanrc); + pr_err("%s: daemon fsck failed with rc=%ld\n", cache->cache.identifier, scanrc); } else { - pr_notice("cachefilesd daemon completed the cache check successfully."); + pr_notice("%s: daemon completed the cache check successfully.\n", + cache->cache.identifier); /* We're no longer dirty, signal the daemon to * let him know that we're happy, and so the * daemon can clean up its fsck resources. */
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 835cbaa..facba8b 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h
@@ -26,8 +26,9 @@ * The cachefiles disk format employed: * * 1: Directory tree mirroring cookie tree. + * 2: As 1 but with indices for faster culling. */ -#define cachefiles_disk_format 1 +#define cachefiles_disk_format 2 struct cachefiles_cache; struct cachefiles_object;
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 5400c36..af5faba 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c
@@ -503,6 +503,9 @@ /* search the current directory for the element name */ _debug("lookup '%s'", name); + ret = mnt_want_write(cache->mnt); + if (ret < 0) + goto error_out2; mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); /* Are you still here, directory? */ @@ -513,6 +516,8 @@ goto error; } /* otherwise... */ + mutex_unlock(&dir->d_inode->i_mutex); + mnt_drop_write(cache->mnt); _debug("dir vanished on us, restarting pathwalk"); goto restart; } @@ -600,6 +605,7 @@ if (key) { _debug("advance"); mutex_unlock(&dir->d_inode->i_mutex); + mnt_drop_write(cache->mnt); dput(dir); dir = next; next = NULL; @@ -613,10 +619,10 @@ * check its attributes and delete it if it's out of date * - this will also retrieve its current cull slot assignment */ + mutex_lock(&cache->xattr_mutex); if (!test_bit(CACHEFILES_OBJECT_NEW, &object->flags)) { _debug("validate '%pd'", next); - mutex_lock(&cache->xattr_mutex); ret = cachefiles_check_object_xattr(object, auxdata); if (ret == -ESTALE) { mutex_unlock(&cache->xattr_mutex); @@ -650,6 +656,7 @@ mutex_unlock(&cache->xattr_mutex); mutex_unlock(&dir->d_inode->i_mutex); + mnt_drop_write(cache->mnt); dput(dir); dir = NULL; @@ -736,6 +743,7 @@ next = NULL; error: mutex_unlock(&dir->d_inode->i_mutex); + mnt_drop_write(cache->mnt); dput(next); error_out2: dput(dir);