Re: [PATCH v2 07/11] btrfs: Add noinode_cache mount option.

2014-01-05 Thread Qu Wenruo

On fri, 3 Jan 2014 18:52:44 +0100, David Sterba wrote:

On Fri, Jan 03, 2014 at 02:10:30PM +0800, Qu Wenruo wrote:

Add noinode_cache mount option to disable inode map cache with
remount option.

This looks almost safe, there's a sync_filesystem called before the
filesystem's remount handler, the transaction gets committed and flushes
all tha data related to inode_cache.

The caching thread keeps running, which is not a serious problem as
it'll finish at umount time, only consuming resources.

There's a window between sync_filesystem and successful remount when the
INODE_MAP_CACHE bit is set and the cache could be used to get a free ino,
then the INODE_MAP_CACHE is cleared but the ino cache remains is not
synced back to disk, normally called from transaction commit via
btrfs_unpin_free_ino. I haven't looked if something else blocks that to
happen.

I'd leave this patch out for now, it probably needs more code updates
than just unsetting the bit.

david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Thanks for pointing out the hidden problem.

I'll check the related source again to keep this behavior safe or
add new codes.

So in next patchset, the inode map cache option will not be included
and will be seperated to a new patch.

Qu
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 07/11] btrfs: Add noinode_cache mount option.

2014-01-03 Thread David Sterba
On Fri, Jan 03, 2014 at 02:10:30PM +0800, Qu Wenruo wrote:
> Add noinode_cache mount option to disable inode map cache with
> remount option.

This looks almost safe, there's a sync_filesystem called before the
filesystem's remount handler, the transaction gets committed and flushes
all tha data related to inode_cache.

The caching thread keeps running, which is not a serious problem as
it'll finish at umount time, only consuming resources.

There's a window between sync_filesystem and successful remount when the
INODE_MAP_CACHE bit is set and the cache could be used to get a free ino,
then the INODE_MAP_CACHE is cleared but the ino cache remains is not
synced back to disk, normally called from transaction commit via
btrfs_unpin_free_ino. I haven't looked if something else blocks that to
happen.

I'd leave this patch out for now, it probably needs more code updates
than just unsetting the bit.

david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 07/11] btrfs: Add noinode_cache mount option.

2014-01-02 Thread Qu Wenruo
Add noinode_cache mount option to disable inode map cache with
remount option.

Signed-off-by: Qu Wenruo 
---
changelog:
v2: Add noinode_cache mount option.
---
 Documentation/filesystems/btrfs.txt | 6 --
 fs/btrfs/super.c| 7 +++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Documentation/filesystems/btrfs.txt 
b/Documentation/filesystems/btrfs.txt
index 516ed65..ffb40f3 100644
--- a/Documentation/filesystems/btrfs.txt
+++ b/Documentation/filesystems/btrfs.txt
@@ -129,9 +129,11 @@ Options with (*) are default options and will not show in 
the mount options.
operations).  This was previously the behavior only when a snapshot is
created.
 
+  noinode_cache(*)
   inode_cache
-   Enable free inode number caching.   Defaults to off due to an overflow
-   problem when the free space crcs don't fit inside a single page.
+   Disable/enable free inode number caching.
+   Defaults to off due to an overflow problem when the free space crcs
+   don't fit inside a single page.
 
   max_inline=
Specify the maximum amount of space, in bytes, that can be inlined in
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c511239..16da3d1 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -325,6 +325,7 @@ enum {
Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree,
Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nocheck_integrity,
Opt_nodiscard, Opt_noenospc_debug, Opt_noflushoncommit,
+   Opt_noinode_cache,
Opt_err,
 };
 
@@ -363,6 +364,7 @@ static match_table_t tokens = {
{Opt_defrag, "autodefrag"},
{Opt_nodefrag, "noautodefrag"},
{Opt_inode_cache, "inode_cache"},
+   {Opt_noinode_cache, "noinode_cache"},
{Opt_no_space_cache, "nospace_cache"},
{Opt_recovery, "recovery"},
{Opt_skip_balance, "skip_balance"},
@@ -602,6 +604,11 @@ int btrfs_parse_options(struct btrfs_root *root, char 
*options)
btrfs_info(root->fs_info, "enabling inode map caching");
btrfs_set_opt(info->mount_opt, INODE_MAP_CACHE);
break;
+   case Opt_noinode_cache:
+   if (btrfs_test_opt(root, INODE_MAP_CACHE))
+   btrfs_info(root->fs_info, "disabling inode map 
caching");
+   btrfs_clear_opt(info->mount_opt, INODE_MAP_CACHE);
+   break;
case Opt_clear_cache:
btrfs_info(root->fs_info, "force clearing of disk 
cache");
btrfs_set_opt(info->mount_opt, CLEAR_CACHE);
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html