Re: [PATCH] Btrfs: add missing blk_finish_plug in btrfs_sync_log()
On Fri, Jan 30, 2015 at 07:42:12PM +0800, Forrest Liu wrote: Add missing blk_finish_plug in btrfs_sync_log() Signed-off-by: Forrest Liu forre...@synology.com Reviewed-by: David Sterba dste...@suse.cz Did you find that by code inspection or was there a runtime problem. Thanks. -- 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
[GIT PULL] Btrfs fix
Hi Linus, We have one more fix for btrfs in my for-linus branch: git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs.git for-linus This was a bug in the new raid5/6 scrubbing support. Gui Hecheng (1) commits (+2/-0): btrfs: fix raid56 scrub failed in xfstests btrfs/072 Total: (1) commits (+2/-0) fs/btrfs/scrub.c | 2 ++ 1 file changed, 2 insertions(+) -- 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] Btrfs: add missing blk_finish_plug in btrfs_sync_log()
On Fri, Jan 30, 2015 at 11:51 AM, David Sterba dste...@suse.cz wrote: On Fri, Jan 30, 2015 at 07:42:12PM +0800, Forrest Liu wrote: Add missing blk_finish_plug in btrfs_sync_log() Signed-off-by: Forrest Liu forre...@synology.com Reviewed-by: David Sterba dste...@suse.cz Did you find that by code inspection or was there a runtime problem. I was wondering the same. I'll send in for 3.19-final -chris -- 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 3.19-rc] btrfs: add read-only check to sysfs handler of features
On Fri, Jan 23, 2015 at 06:52:11PM +0100, David Sterba wrote: We don't want to trigger the change on a read-only filesystem, similar to what the label handler does. Signed-off-by: David Sterba dste...@suse.cz Please drop this patch, seems that the right way to the ro/rw freeze protection is to use sb_start_write co. -- 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 RFC v3 1/5] Revert btrfs: add support for processing pending changes related commits
On Thu, Jan 29, 2015 at 09:15:12AM +0800, Qu Wenruo wrote: Are we sure that there's no possible deadlock when we eg. change the label via sysfs in the middle of a balance that removes some of the files? Or other combination of operations. Can we guarantee that this will be ok in the long term and not introduced accidentally? For me, I didn't see the difference between VFS staff and sysfs/kernfs staff. They both have their own locking things which is out of the control of btrfs. VFS is a close neighbor in the layering, syscalls come through it, affects filesystem state very often and API changes propagate to all the filesystems. Sysfs provides us some API but in a very limited scope compared to VFS. But we are still using VFS staffs, right? If we want to use sysfs interfaces to do things like change label, then it's our responsibility to ensure things works fine. I absolutelly agree with that and that's why I'm trying to minimize the potential traps when the subsystems become interconnected too closely, eg. depending on internal locks. If not we should either modify btrfs or sysfs to do it, just like what we were doing with VFS staffs. This means changing innternal workings of the two, this seems unlikely as we're mere users for them. Though we can bring new requests for API or some such, we can't easily affect their internal logic just because it's easy for us to throw a transaction commit somewhere and stop caring. To ensure the cooperation works fine, we just need extra testcases, much like what we were doing. So IMHO, I didn't really see the difference between VFS and sysfs staffs (except sysfs is not so wided adapted). We just needs to do all the old style work, modify btrfs or sysfs or both and, and add tons of test case. And I see a big difference, if nothing else, sysfs is user of VFS layer. -- 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
rolling back to ext4 doesn't work if rebalanced
Is it possible to automate btrfs-convert so that it would defrag and balance the disk without loosing ability to roll back to ext4 partition ? i.e: btrfs-convert /dev/sda3 # I can still rollback using btrfs-convert -r /dev/sda3 btrfs filesystem defrag -r / # I can still rollback using btrfs-convert -r /dev/sda3 btrfs balance start / # I can no longer rollback to ext4 -Vytas P.S. btrfs version Btrfs v3.17 -- 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: btrfs send multiple subvolumes
Hi, just wanted to say that I'm having the very same issue with kernel 3.18.4, btrfs-progs 3.18.1 (with or without -e option) - even with completely fresh and/or empty snapshots. I'm just starting to experiment with send/receive, so I don't know whether I have a fundamentally wrong idea what it should do, but it seems to me like a quite standard case. Any news of this? Best, Sebastian -- 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 v5 5/9] btrfs: Use btrfs_test_trans_opt() to handle INODE_CACHE if it's under transaction protect.
On Fri, Jan 30, 2015 at 05:20:50PM +0800, Qu Wenruo wrote: Convert btrfs_test_opt() to btrfs_test_trans_opt() if it's called under transaction protection. This will ensure SPACE_CACHE bit is consistent during transaction. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com Reviewed-by: David Sterba dste...@suse.cz -- 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 v5 6/9] vfs: Add sb_want_write() function to get vfsmount from a given sb.
On Fri, Jan 30, 2015 at 05:20:51PM +0800, Qu Wenruo wrote: So introduce new sb_want_write() to do the protection agains a super block, which acts much like mnt_want_write() but will return success if the super block is read-write. I like the new interface and think that it could be used in the per-fs background threads instead of the raw MS_RDONLY checks. From a brief look it may not apply everywhere as sb_start_write could wait, but there are a few candidates. Cc: linux-fsdevel linux-fsde...@vger.kernel.org Signed-off-by: Al Viro v...@zeniv.linux.org.uk Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com Reviewed-by: David Sterba dste...@suse.cz -- 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 v5 0/9] btrfs: Fix freeze/sysfs deadlock in better method.
On Fri, Jan 30, 2015 at 05:20:45PM +0800, Qu Wenruo wrote: [Use VFS protect for sysfs change] The 6th patch will introduce a new help function sb_want_write() to claim write permission to a superblock. With this, we are able to do write protection like mnt_want_write() but only needs to ensure that the superblock is writeable. This also keeps the same synchronized behavior using ioctl, which will block on frozen fs until it is unfrozen. You know what I think abuot the commit inside sysfs, but it looks better to me now with the sb_* protections so I give it a go. -- 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 v5 4/9] btrfs: Use btrfs_test_trans_opt() to handle SPACE_CACHE if it's under transaction protect.
On Fri, Jan 30, 2015 at 05:20:49PM +0800, Qu Wenruo wrote: Convert btrfs_test_opt() to btrfs_test_trans_opt() if it's called under transaction protection. This will ensure SPACE_CACHE bit is consistent during transaction. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com Reviewed-by: David Sterba dste...@suse.cz -- 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 v5 9/9] btrfs: Use sb_want_write() to protect sysfs feature change.
On Fri, Jan 30, 2015 at 05:20:54PM +0800, Qu Wenruo wrote: --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -154,9 +154,15 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj, btrfs_info(fs_info, %s %s feature flag, val ? Setting : Clearing, fa-kobj_attr.attr.name); + ret = sb_want_write(fs_info-sb); + if (ret) + return ret; Same here, move it to the beginning, right after fs_info is validated. + trans = btrfs_start_transaction(fs_info-fs_root, 0); - if (IS_ERR(trans)) - return PTR_ERR(trans); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); + goto out; + } -- 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 v5 2/9] btrfs: Make btrfs_parse_options() parse mount option in a atomic way
On Fri, Jan 30, 2015 at 05:20:47PM +0800, Qu Wenruo wrote: v5: Add ACCESS_ONE() macro to avoid aggressive compiler optimization to not read fs_info-mount_opt to new_opt but always use fs_info-mount_opt. This holds only up to this patch, ie. that there are other threads that could change value of fs_info-mount_opt concurrently. But then the per-transaction mount options will avoid that as space cache status will be unmodified by remounts (through parse_options). So either drop ACCESS_ONCE or please write a comment and explain why it's still needed. -- 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 v5 8/9] btrfs: Use sb_want_write() to protect label change.
On Fri, Jan 30, 2015 at 05:20:53PM +0800, Qu Wenruo wrote: Use the new vfs API sb_want_write() to do the write protection of the label change transaction. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com --- v4: Newly introduced. v5: Change to use sb_want_write(). --- fs/btrfs/sysfs.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index b2e7bb4..3218245 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -25,6 +25,7 @@ #include linux/bug.h #include linux/genhd.h #include linux/debugfs.h +#include linux/mount.h #include ctree.h #include disk-io.h @@ -377,8 +378,6 @@ static ssize_t btrfs_label_store(struct kobject *kobj, int ret; size_t p_len; - if (fs_info-sb-s_flags MS_RDONLY) - return -EROFS; /* * p_len is the len until the first occurrence of either @@ -389,9 +388,15 @@ static ssize_t btrfs_label_store(struct kobject *kobj, if (p_len = BTRFS_LABEL_SIZE) return -EINVAL; + ret = sb_want_write(fs_info-sb); + if (ret) + return ret; Please move the check to the beginning of the function, where the original MS_RDONLY check was. + trans = btrfs_start_transaction(root, 0); - if (IS_ERR(trans)) - return PTR_ERR(trans); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); + goto out; + } spin_lock(root-fs_info-super_lock); memset(fs_info-super_copy-label, 0, BTRFS_LABEL_SIZE); @@ -399,9 +404,10 @@ static ssize_t btrfs_label_store(struct kobject *kobj, spin_unlock(root-fs_info-super_lock); ret = btrfs_commit_transaction(trans, root); +out: + sb_drop_write(fs_info-sb); if (!ret) return len; - return ret; } BTRFS_ATTR_RW(label, btrfs_label_show, btrfs_label_store); -- 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 v5 1/9] Revert btrfs: add support for processing pending changes related commits
On Fri, Jan 30, 2015 at 05:20:46PM +0800, Qu Wenruo wrote: This reverts commit 572d9ab7845 ~ a6f69dc8018. This pending commits patches introduce deadlock with freeze, and fix for it will introduce extra checks on freeze and read only case. For mount option change, later patches will introduce per-transaction mount option to keep mount options consistent during transaction. For sysfs interface to change label/features, it will use mnt_want_write() to do the ro/freeze check and keep the 'btrfs pro set' synchronized behavior. Revert them to a clean base for later changes. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com With the improved fix in place Acked-by: David Sterba dste...@suse.cz -- 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 v5 0/9] btrfs: Fix freeze/sysfs deadlock in better method.
On Fri, 30 Jan 2015 20:17:49 +0100, David Sterba wrote: On Fri, Jan 30, 2015 at 05:20:45PM +0800, Qu Wenruo wrote: [Use VFS protect for sysfs change] The 6th patch will introduce a new help function sb_want_write() to claim write permission to a superblock. With this, we are able to do write protection like mnt_want_write() but only needs to ensure that the superblock is writeable. This also keeps the same synchronized behavior using ioctl, which will block on frozen fs until it is unfrozen. You know what I think abuot the commit inside sysfs, but it looks better to me now with the sb_* protections so I give it a go. -- 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 I worried about the following case # fsfreeze btrfs # echo new label btrfs_sysfs It should be hangup On the other terminal # umount btrfs Because the 2nd echo command didn't increase mount reference, so umount would not know someone still blocked on the fs, it would not go back and return EBUSY like someone access the fs by common fs interface, it would deactive fs directly and then blocked on sysfs removal. Thanks Miao -- 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: rolling back to ext4 doesn't work if rebalanced
Vytautas D posted on Fri, 30 Jan 2015 16:41:11 + as excerpted: Is it possible to automate btrfs-convert so that it would defrag and balance the disk without loosing ability to roll back to ext4 partition ? i.e: btrfs-convert /dev/sda3 # I can still rollback using btrfs-convert -r /dev/sda3 btrfs filesystem defrag -r / # I can still rollback using btrfs-convert -r /dev/sda3 btrfs balance start / # I can no longer rollback to ext4 Mostly no, tho in theory there's also a very narrow and limited yes. (Semi-)technical background: The ext* fs layout is quite a bit different than btrfs' native layout, metadata more so than data. What the conversion actually does is leave the ext* data in-place, along with its metadata, and in the free space that still existed on the ext* filesystem, create new btrfs metadata pointing at the still-in-place ext* file data. Because btrfs is copy-on-write (COW), and the conversion process creates a special btrfs snapshot containing the ext* data and metadata so btrfs won't remove it if it updates files, you can write new data and changes to the existing data on the btrfs side, and btrfs will write that to a different location, leaving the ext* data and metadata in that special snapshot as they were. It is for that reason that any changes made while the filesystem is btrfs won't be retained if you convert back to ext*. You get the ext* filesystem as it was at the time of the conversion to btrfs. If you decide to stay with btrfs, the first thing to do is remove that special ext*_saved (IIRC that's the name, something like that) snapshot, then defrag and balance what remains, obliterating the ext* metadata and final-converting all the data to native btrfs format. The key concept to understand here is that btrfs itself doesn't understand or deal with the ext* metadata at all. The (userspace) conversion process simply creates new btrfs metadata pointing at the existing ext* data, and takes advantage of btrfs' COW nature to create a snapshot that btrfs shouldn't touch, so as to keep the ext* metadata and data intact, and along with it, the ability to rollback to that ext* filesystem as it was at the time of the conversion. That's the background. Now to answer your question. What (btrfs) defrag and balance do are two different stages of btrfs- specific optimization. That btrfs-specific optimization simply cannot be done without disrupting the ext* layout, thus the overall no. Actually, even the btrfs fi defrag would normally destroy the ability to rollback, but for one hopefully temporary issue. Ideally, btrfs defrag is snapshot aware, and defragging files in one snapshot will defrag them, to the extent that they are the same, in other snapshots as well. However, the original btrfs snapshot-aware defrag was found not to scale at all well, requiring huge amounts of memory and taking days and sometimes weeks to get thru a defrag in the presence of large numbers of snapshots (with btrfs quotas being another complicating factor at the time). Thus, snapshot-aware-defrag was disabled (hopefully) temporarily, while they rewrote both the multi-snapshot handling code and the quota handling code with a view toward *MUCH* better scaling. At least some of that work has been done and scaling is definitely better now, but apparently not good enough yet that they feel comfortable reenabling snapshot-aware-defrag. Thus, at least for the time being, btrfs defrag is not snapshot aware, and only rewrites the snapshot-instance of the files it's actually pointed at, using COW so anything that's defragged is actually rewritten, leaving other snapshots of the same files in place, as fragmented as they were before. This does the defrag for whatever it's pointed at, but obviously, if the snapshotted files were heavily fragmented, it's going to about double the space taken up, because the snapshotted versions will still exist, while the defrag writes new, defragmented copies, for whatever mounted snapshot you pointed the defrag at. That's why you could btrfs defrag and still successfully roll-back to ext*, because the ext* is its own snapshot, and with snapshot-aware- defrag temporarily disabled, the defrag rewrote any files it defragged, creating a new copy of them, while leaving the existing ext* special snapshot alone. When snapshot-aware-defrag is reenabled, that won't (normally) work any more, as the files in the snapshot would be btrfs defragged as well, thereby moving them out from under the ext* metadata pointing at the old copies. All that said, at least in theory, balance and defrag could be taught to special-case the ext* snapshot, leaving it alone, while balancing and defragging the btrfs metadata, along with any files added or changed since the btrfs conversion, which thus exist on the btrfs side. That's the very limited yes I mentioned above. But that's only theory, and in practice it'd hardly be worth
Re: Indefinite hang in reserve_metadata_bytes on kernel 3.18.3
On Thu, 29 Jan 2015 22:50:20 +, Steven Schlansker wrote: Thank you for the suggestion. I did not find a 3.18.5 presented in any form other than as a large number of *.patch files, so I went for 3.19-rc6 instead (which I verified has this commit) 3.18.5 is out now but it shouldn't matter, in your case it looks like something else is wrong. Now I am getting: [ 1224.728313] [ cut here ] [ 1224.728323] kernel BUG at fs/btrfs/extent-tree.c:7362! That's -ENOMEM in btrfs_alloc_tree_block(), no definite idea what could (really) cause that. In any case your first order of business should be to get an up-to-date btrfs-progs (= 3.18.2) and see what a check says. Your 3.12 is really old. Another thing that I found helpful is to mount the fs in question at least once without the free-space-cache, aka with -o clear_cache,nospace_cache options. btrfs tries to detect whether this cache is out of sync/corrupted, but I've seen it lead to weird problems down the road on rare occasion. So mount the fs without it, maybe do a little cleanup/work, cleanly unmount it and then try to remount/work with the cache enabled. If you first created worked on this fs with 3.13 you may have other yet undetected problems lurking. That's really all I can recommend for now from here. Good luck! -h -- 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 v5 9/9] btrfs: Use sb_want_write() to protect sysfs feature change.
Just like label change, use sb_want_write() to do a correct protection. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com --- v4: Newly introduced. v5: Change to sb_want_write(). --- fs/btrfs/sysfs.c | 18 +- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 3218245..64f876e 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -154,9 +154,15 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj, btrfs_info(fs_info, %s %s feature flag, val ? Setting : Clearing, fa-kobj_attr.attr.name); + ret = sb_want_write(fs_info-sb); + if (ret) + return ret; + trans = btrfs_start_transaction(fs_info-fs_root, 0); - if (IS_ERR(trans)) - return PTR_ERR(trans); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); + goto out; + } spin_lock(fs_info-super_lock); features = get_features(fs_info, fa-feature_set); @@ -168,10 +174,12 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj, spin_unlock(fs_info-super_lock); ret = btrfs_commit_transaction(trans, fs_info-fs_root); - if (ret) - return ret; - return count; +out: + sb_drop_write(fs_info-sb); + if (!ret) + return count; + return ret; } static umode_t btrfs_feature_visible(struct kobject *kobj, -- 2.2.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
[PATCH v5 4/9] btrfs: Use btrfs_test_trans_opt() to handle SPACE_CACHE if it's under transaction protect.
Convert btrfs_test_opt() to btrfs_test_trans_opt() if it's called under transaction protection. This will ensure SPACE_CACHE bit is consistent during transaction. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com --- changelog: v3: Newly introduced. v4~v5: None --- fs/btrfs/extent-tree.c | 2 +- fs/btrfs/transaction.c | 7 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a684086..fde502c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3260,7 +3260,7 @@ again: spin_lock(block_group-lock); if (block_group-cached != BTRFS_CACHE_FINISHED || - !btrfs_test_opt(root, SPACE_CACHE) || + !btrfs_test_trans_opt(trans, SPACE_CACHE) || block_group-delalloc_bytes) { /* * don't bother trying to write stuff out _if_ diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 846e1b8..aec5a5a 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1507,7 +1507,8 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans, return ret; } -static void update_super_roots(struct btrfs_root *root) +static void update_super_roots(struct btrfs_trans_handle *trans, + struct btrfs_root *root) { struct btrfs_root_item *root_item; struct btrfs_super_block *super; @@ -1523,7 +1524,7 @@ static void update_super_roots(struct btrfs_root *root) super-root = root_item-bytenr; super-generation = root_item-generation; super-root_level = root_item-level; - if (btrfs_test_opt(root, SPACE_CACHE)) + if (btrfs_test_trans_opt(trans, SPACE_CACHE)) super-cache_generation = root_item-generation; if (root-fs_info-update_uuid_tree_gen) super-uuid_tree_generation = root_item-generation; @@ -1987,7 +1988,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, switch_commit_roots(cur_trans, root-fs_info); assert_qgroups_uptodate(trans); - update_super_roots(root); + update_super_roots(trans, root); btrfs_set_super_log_root(root-fs_info-super_copy, 0); btrfs_set_super_log_root_level(root-fs_info-super_copy, 0); -- 2.2.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
[PATCH v5 6/9] vfs: Add sb_want_write() function to get vfsmount from a given sb.
There are sysfs interfaces in some fs, only btrfs yet, which will modify on-disk data. Unlike normal file operation routine we can use mnt_want_write_file() to protect the operation, change through sysfs won't to be binded to any file in the filesystem. So introduce new sb_want_write() to do the protection agains a super block, which acts much like mnt_want_write() but will return success if the super block is read-write. Cc: linux-fsdevel linux-fsde...@vger.kernel.org Signed-off-by: Al Viro v...@zeniv.linux.org.uk Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com --- Changelog: v4: Newly introduced. v5: Change name to sb_want_write() and receive sb and parameter. --- fs/namespace.c| 36 include/linux/mount.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/fs/namespace.c b/fs/namespace.c index cd1e968..79bc762 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1105,6 +1105,42 @@ struct vfsmount *mntget(struct vfsmount *mnt) } EXPORT_SYMBOL(mntget); +/** + * sb_want_write - get write acess to a super block + * @sb: the superblock of the filesystem + * + * This tells the low-level filesystem that a write is about to be performed to + * it, and makes sure that the writes are allowed (superblock is read-write, + * filesystem is not frozen) before returning success. + * When the write operation is finished, sb_drop_write() must be called. + * This is much like mnt_want_write() as a refcount, but only needs + * the superblock to be read-write. + */ +int sb_want_write(struct super_block *sb) +{ + sb_start_write(sb); + if (sb-s_readonly_remount || sb-s_flags MS_RDONLY) { + sb_end_write(sb); + return -EROFS; + } + return 0; +} +EXPORT_SYMBOL(sb_want_write); + +/** + * sb_drop_write - give up write acess to a super block + * @sb: the superblock on which to give up write access + * + * Tells the low-level filesystem that we are done performing writes to it and + * also allows filesystem to be frozen again. Must be matched with + * sb_want_write() call above. + */ +void sb_drop_write(struct super_block *sb) +{ + sb_end_write(sb); +} +EXPORT_SYMBOL(sb_drop_write); + struct vfsmount *mnt_clone_internal(struct path *path) { struct mount *p; diff --git a/include/linux/mount.h b/include/linux/mount.h index c2c561d..abf4495 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -74,8 +74,10 @@ struct path; extern int mnt_want_write(struct vfsmount *mnt); extern int mnt_want_write_file(struct file *file); extern int mnt_clone_write(struct vfsmount *mnt); +extern int sb_want_write(struct super_block *sb); extern void mnt_drop_write(struct vfsmount *mnt); extern void mnt_drop_write_file(struct file *file); +extern void sb_drop_write(struct super_block *sb); extern void mntput(struct vfsmount *mnt); extern struct vfsmount *mntget(struct vfsmount *mnt); extern struct vfsmount *mnt_clone_internal(struct path *path); -- 2.2.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
[PATCH v5 8/9] btrfs: Use sb_want_write() to protect label change.
Use the new vfs API sb_want_write() to do the write protection of the label change transaction. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com --- v4: Newly introduced. v5: Change to use sb_want_write(). --- fs/btrfs/sysfs.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index b2e7bb4..3218245 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -25,6 +25,7 @@ #include linux/bug.h #include linux/genhd.h #include linux/debugfs.h +#include linux/mount.h #include ctree.h #include disk-io.h @@ -377,8 +378,6 @@ static ssize_t btrfs_label_store(struct kobject *kobj, int ret; size_t p_len; - if (fs_info-sb-s_flags MS_RDONLY) - return -EROFS; /* * p_len is the len until the first occurrence of either @@ -389,9 +388,15 @@ static ssize_t btrfs_label_store(struct kobject *kobj, if (p_len = BTRFS_LABEL_SIZE) return -EINVAL; + ret = sb_want_write(fs_info-sb); + if (ret) + return ret; + trans = btrfs_start_transaction(root, 0); - if (IS_ERR(trans)) - return PTR_ERR(trans); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); + goto out; + } spin_lock(root-fs_info-super_lock); memset(fs_info-super_copy-label, 0, BTRFS_LABEL_SIZE); @@ -399,9 +404,10 @@ static ssize_t btrfs_label_store(struct kobject *kobj, spin_unlock(root-fs_info-super_lock); ret = btrfs_commit_transaction(trans, root); +out: + sb_drop_write(fs_info-sb); if (!ret) return len; - return ret; } BTRFS_ATTR_RW(label, btrfs_label_show, btrfs_label_store); -- 2.2.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
[PATCH v5 2/9] btrfs: Make btrfs_parse_options() parse mount option in a atomic way
Current btrfs_parse_options() is not atomic, which can set and clear a bit, especially for nospace_cache case. For example, if a fs is mounted with nospace_cache, btrfs_parse_options() will set SPACE_CACHE bit first(since cache_generation is non-zeo) and clear the SPACE_CACHE bit due to nospace_cache mount option. So under heavy operations and remount a nospace_cache btrfs, there is a windows for commit to create space cache. This bug can be reproduced by fstest/btrfs/071 073 074 with nospace_cache mount option. It has about 50% chance to create space cache, and about 10% chance to create wrong space cache, which can't pass btrfsck. This patch will do the mount option parse in a copy-and-update method. First copy the mount_opt from fs_info to new_opt, and only update options in new_opt. At last, copy the new_opt back to fs_info-mount_opt. This patch is already good enough to fix the above nospace_cache + remount bug, but need later patch to make sure mount options does not change during transaction. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com --- changelog: v3: Newly introduced v4: None v5: Add ACCESS_ONE() macro to avoid aggressive compiler optimization to not read fs_info-mount_opt to new_opt but always use fs_info-mount_opt. --- fs/btrfs/ctree.h | 16 fs/btrfs/super.c | 115 +-- 2 files changed, 69 insertions(+), 62 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 08741e8..0d44ea9 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2120,18 +2120,18 @@ struct btrfs_ioctl_defrag_range_args { #define btrfs_test_opt(root, opt) ((root)-fs_info-mount_opt \ BTRFS_MOUNT_##opt) -#define btrfs_set_and_info(root, opt, fmt, args...)\ +#define btrfs_set_and_info(fs_info, val, opt, fmt, args...)\ { \ - if (!btrfs_test_opt(root, opt)) \ - btrfs_info(root-fs_info, fmt, ##args); \ - btrfs_set_opt(root-fs_info-mount_opt, opt); \ + if (!btrfs_raw_test_opt(val, opt)) \ + btrfs_info(fs_info, fmt, ##args); \ + btrfs_set_opt(val, opt);\ } -#define btrfs_clear_and_info(root, opt, fmt, args...) \ +#define btrfs_clear_and_info(fs_info, val, opt, fmt, args...) \ { \ - if (btrfs_test_opt(root, opt)) \ - btrfs_info(root-fs_info, fmt, ##args); \ - btrfs_clear_opt(root-fs_info-mount_opt, opt); \ + if (btrfs_raw_test_opt(val, opt)) \ + btrfs_info(fs_info, fmt, ##args); \ + btrfs_clear_opt(val, opt); \ } /* diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index b0c45b2..3ea3ce3 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -395,10 +395,13 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) int ret = 0; char *compress_type; bool compress_force = false; + unsigned long new_opt; + + new_opt = ACCESS_ONCE(info-mount_opt); cache_gen = btrfs_super_cache_generation(root-fs_info-super_copy); if (cache_gen) - btrfs_set_opt(info-mount_opt, SPACE_CACHE); + btrfs_set_opt(new_opt, SPACE_CACHE); if (!options) goto out; @@ -422,7 +425,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) switch (token) { case Opt_degraded: btrfs_info(root-fs_info, allowing degraded mounts); - btrfs_set_opt(info-mount_opt, DEGRADED); + btrfs_set_opt(new_opt, DEGRADED); break; case Opt_subvol: case Opt_subvolid: @@ -434,7 +437,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) */ break; case Opt_nodatasum: - btrfs_set_and_info(root, NODATASUM, + btrfs_set_and_info(info, new_opt, NODATASUM, setting nodatasum); break; case Opt_datasum: @@ -444,8 +447,8 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) else btrfs_info(root-fs_info, setting datasum); } - btrfs_clear_opt(info-mount_opt, NODATACOW); - btrfs_clear_opt(info-mount_opt, NODATASUM); +
[PATCH v5 1/9] Revert btrfs: add support for processing pending changes related commits
This reverts commit 572d9ab7845 ~ a6f69dc8018. This pending commits patches introduce deadlock with freeze, and fix for it will introduce extra checks on freeze and read only case. For mount option change, later patches will introduce per-transaction mount option to keep mount options consistent during transaction. For sysfs interface to change label/features, it will use mnt_want_write() to do the ro/freeze check and keep the 'btrfs pro set' synchronized behavior. Revert them to a clean base for later changes. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com Conflicts: fs/btrfs/ctree.h fs/btrfs/super.c --- changelog: v2: Newly introduced. v3~v5: None --- fs/btrfs/ctree.h | 49 + fs/btrfs/disk-io.c | 8 +++- fs/btrfs/inode-map.c | 2 +- fs/btrfs/super.c | 24 +++- fs/btrfs/sysfs.c | 34 +- fs/btrfs/transaction.c | 38 ++ fs/btrfs/transaction.h | 2 -- 7 files changed, 35 insertions(+), 122 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0b18070..08741e8 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1412,11 +1412,6 @@ struct btrfs_fs_info { */ u64 last_trans_log_full_commit; unsigned long mount_opt; - /* -* Track requests for actions that need to be done during transaction -* commit (like for some mount options). -*/ - unsigned long pending_changes; unsigned long compress_type:4; int commit_interval; /* @@ -2114,6 +2109,7 @@ struct btrfs_ioctl_defrag_range_args { #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 21) #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 22) #define BTRFS_MOUNT_RESCAN_UUID_TREE (1 23) +#defineBTRFS_MOUNT_CHANGE_INODE_CACHE (1 24) #define BTRFS_DEFAULT_COMMIT_INTERVAL (30) #define BTRFS_DEFAULT_MAX_INLINE (8192) @@ -2139,49 +2135,6 @@ struct btrfs_ioctl_defrag_range_args { } /* - * Requests for changes that need to be done during transaction commit. - * - * Internal mount options that are used for special handling of the real - * mount options (eg. cannot be set during remount and have to be set during - * transaction commit) - */ - -#define BTRFS_PENDING_SET_INODE_MAP_CACHE (0) -#define BTRFS_PENDING_CLEAR_INODE_MAP_CACHE(1) -#define BTRFS_PENDING_COMMIT (2) - -#define btrfs_test_pending(info, opt) \ - test_bit(BTRFS_PENDING_##opt, (info)-pending_changes) -#define btrfs_set_pending(info, opt) \ - set_bit(BTRFS_PENDING_##opt, (info)-pending_changes) -#define btrfs_clear_pending(info, opt) \ - clear_bit(BTRFS_PENDING_##opt, (info)-pending_changes) - -/* - * Helpers for setting pending mount option changes. - * - * Expects corresponding macros - * BTRFS_PENDING_SET_ and CLEAR_ + short mount option name - */ -#define btrfs_set_pending_and_info(info, opt, fmt, args...)\ -do { \ - if (!btrfs_raw_test_opt((info)-mount_opt, opt)) { \ - btrfs_info((info), fmt, ##args);\ - btrfs_set_pending((info), SET_##opt); \ - btrfs_clear_pending((info), CLEAR_##opt); \ - } \ -} while(0) - -#define btrfs_clear_pending_and_info(info, opt, fmt, args...) \ -do { \ - if (btrfs_raw_test_opt((info)-mount_opt, opt)) { \ - btrfs_info((info), fmt, ##args);\ - btrfs_set_pending((info), CLEAR_##opt); \ - btrfs_clear_pending((info), SET_##opt); \ - } \ -} while(0) - -/* * Inode flags */ #define BTRFS_INODE_NODATASUM (1 0) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8c63419..2d3c8b7 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2832,11 +2832,9 @@ retry_root_backup: btrfs_set_opt(fs_info-mount_opt, SSD); } - /* -* Mount does not set all options immediatelly, we can do it now and do -* not have to wait for transaction commit -*/ - btrfs_apply_pending_changes(fs_info); + /* Set the real inode map cache flag */ + if (btrfs_test_opt(tree_root, CHANGE_INODE_CACHE)) + btrfs_set_opt(tree_root-fs_info-mount_opt, INODE_MAP_CACHE); #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY if (btrfs_test_opt(tree_root, CHECK_INTEGRITY)) { diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index 74faea3..81efd83 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c @@ -178,7 +178,7
[PATCH v5 5/9] btrfs: Use btrfs_test_trans_opt() to handle INODE_CACHE if it's under transaction protect.
Convert btrfs_test_opt() to btrfs_test_trans_opt() if it's called under transaction protection. This will ensure SPACE_CACHE bit is consistent during transaction. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com --- Changelog: v3: Newly introduced. v4~v5: None --- fs/btrfs/ctree.h| 1 - fs/btrfs/disk-io.c | 4 fs/btrfs/free-space-cache.c | 2 +- fs/btrfs/inode-map.c| 5 +++-- fs/btrfs/transaction.c | 9 - 5 files changed, 4 insertions(+), 17 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0d44ea9..f381ae8 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2109,7 +2109,6 @@ struct btrfs_ioctl_defrag_range_args { #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 21) #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 22) #define BTRFS_MOUNT_RESCAN_UUID_TREE (1 23) -#defineBTRFS_MOUNT_CHANGE_INODE_CACHE (1 24) #define BTRFS_DEFAULT_COMMIT_INTERVAL (30) #define BTRFS_DEFAULT_MAX_INLINE (8192) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 2d3c8b7..f4d168d 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2832,10 +2832,6 @@ retry_root_backup: btrfs_set_opt(fs_info-mount_opt, SSD); } - /* Set the real inode map cache flag */ - if (btrfs_test_opt(tree_root, CHANGE_INODE_CACHE)) - btrfs_set_opt(tree_root-fs_info-mount_opt, INODE_MAP_CACHE); - #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY if (btrfs_test_opt(tree_root, CHECK_INTEGRITY)) { ret = btrfsic_mount(tree_root, fs_devices, diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index d6c03f7..2b9cabf 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -3348,7 +3348,7 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root, struct btrfs_free_space_ctl *ctl = root-free_ino_ctl; int ret; - if (!btrfs_test_opt(root, INODE_MAP_CACHE)) + if (!btrfs_test_trans_opt(trans, INODE_MAP_CACHE)) return 0; ret = __btrfs_write_out_cache(root, inode, ctl, NULL, trans, path, 0); diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index 81efd83..49b089c 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c @@ -178,7 +178,8 @@ static void start_caching(struct btrfs_root *root) root-root_key.objectid); if (IS_ERR(tsk)) { btrfs_warn(root-fs_info, failed to start inode caching task); - btrfs_clear_and_info(root, CHANGE_INODE_CACHE, + btrfs_clear_and_info(root-fs_info, root-fs_info-mount_opt, + INODE_MAP_CACHE, disabling inode map caching); } } @@ -405,7 +406,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root, if (btrfs_root_refs(root-root_item) == 0) return 0; - if (!btrfs_test_opt(root, INODE_MAP_CACHE)) + if (!btrfs_test_trans_opt(trans, INODE_MAP_CACHE)) return 0; path = btrfs_alloc_path(); diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index aec5a5a..dd9e7af 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1939,15 +1939,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, goto scrub_continue; } - /* -* Since the transaction is done, we should set the inode map cache flag -* before any other comming transaction. -*/ - if (btrfs_test_opt(root, CHANGE_INODE_CACHE)) - btrfs_set_opt(root-fs_info-mount_opt, INODE_MAP_CACHE); - else - btrfs_clear_opt(root-fs_info-mount_opt, INODE_MAP_CACHE); - /* commit_fs_roots gets rid of all the tree log roots, it is now * safe to free the root of tree log roots */ -- 2.2.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
[PATCH v5 7/9] btrfs: Move btrfs_sysfs_remove_one(fs_info) before transcation thread cleanup.
Since btrfs sysfs interfaces can start new transaction, we need to do it before transaction thread cleanup. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com --- v5: Newly introduced. --- fs/btrfs/disk-io.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index f4d168d..7c185a0 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3630,6 +3630,12 @@ void close_ctree(struct btrfs_root *root) fs_info-closing = 1; smp_mb(); + /* +* Remove btrfs sysfs interfaces first, +* since it can start new transaction. +*/ + btrfs_sysfs_remove_one(fs_info); + /* wait for the uuid_scan task to finish */ down(fs_info-uuid_tree_rescan_sem); /* avoid complains from lockdep et al., set sem back to initial state */ @@ -3673,8 +3679,6 @@ void close_ctree(struct btrfs_root *root) percpu_counter_sum(fs_info-delalloc_bytes)); } - btrfs_sysfs_remove_one(fs_info); - btrfs_free_fs_roots(fs_info); btrfs_put_block_group_cache(fs_info); -- 2.2.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
[PATCH v5 3/9] btrfs: Introduce per-transaction mount_opt to keep mount option consistent during transaction.
Before this patch, mount_opt is not consistent during a transaction. btrfs_parse_options() can race with transaction. Now each transaction will keep a copy of fs_info-mount_opt upon creation, and new btrfs_test_trans_opt() macro is introduced to get the mount_opt in the transaction. Signed-off-by: Qu Wenruo quwen...@cn.fujitsu.com --- changelog: v3: Newly introduced. v4~v5: None --- fs/btrfs/transaction.c | 1 + fs/btrfs/transaction.h | 4 2 files changed, 5 insertions(+) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 295a135..846e1b8 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -210,6 +210,7 @@ loop: return -EROFS; } + cur_trans-mount_opt = fs_info-mount_opt; atomic_set(cur_trans-num_writers, 1); extwriter_counter_init(cur_trans, type); init_waitqueue_head(cur_trans-writer_wait); diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index fd400a3..4052879 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -52,6 +52,7 @@ struct btrfs_transaction { struct list_head list; struct extent_io_tree dirty_pages; unsigned long start_time; + unsigned long mount_opt; wait_queue_head_t writer_wait; wait_queue_head_t commit_wait; struct list_head pending_snapshots; @@ -126,6 +127,9 @@ struct btrfs_pending_snapshot { struct list_head list; }; +#define btrfs_test_trans_opt(trans, opt) \ + (btrfs_raw_test_opt(trans-transaction-mount_opt, opt)) + static inline void btrfs_set_inode_last_trans(struct btrfs_trans_handle *trans, struct inode *inode) { -- 2.2.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
[PATCH v5 0/9] btrfs: Fix freeze/sysfs deadlock in better method.
Patchset to solve the previous found freeze/sysfs deadlock. Unlike previous pending_changes, which uses transaction commits to ensure mount option doesn't change during transaction. This idea is great in concept, but will introduce extra and somewhat duplicated ro/freeze check, and the original synchronized behavior is also changed. [Per-transaction mount option] This patch use the RCU-like concept, which will copy the mount_opt from fs_info into btrfs_transaction, and each btrfs_test_opt() for specific mount option bit(SPACE_CACHE/INODE_MAP_CACHE) should be changed to btrfs_test_trans_opt(). So mount option during transaction won't be changed, and also, no extra read_only or freeze check is needed, the commit routine is also untouched. [Use VFS protect for sysfs change] The 6th patch will introduce a new help function sb_want_write() to claim write permission to a superblock. With this, we are able to do write protection like mnt_want_write() but only needs to ensure that the superblock is writeable. This also keeps the same synchronized behavior using ioctl, which will block on frozen fs until it is unfrozen. Changelog: v1: Only use cheap freeze check to avoid deadlock. v2: Fix the never changed pending_changes bug and handle transaction in btrfs_freeze() Revert sysfs only functions. v3: Add atomic mount option change and per-trans mount option. Revert all pending changes functions. v4: Add mnt_want_write() in sysfs handler. v5: Change VFS helper name to sb_want_write() and sb_drop_write(). Fix a free-n-use bug where sysfs can start a transaction but transaction thread is freed before btrfs sysfs interfaces. Qu Wenruo (9): Revert btrfs: add support for processing pending changes related commits btrfs: Make btrfs_parse_options() parse mount option in a atomic way btrfs: Introduce per-transaction mount_opt to keep mount option consistent during transaction. btrfs: Use btrfs_test_trans_opt() to handle SPACE_CACHE if it's under transaction protect. btrfs: Use btrfs_test_trans_opt() to handle INODE_CACHE if it's under transaction protect. vfs: Add sb_want_write() function to get vfsmount from a given sb. btrfs: Move btrfs_sysfs_remove_one(fs_info) before transcation thread cleanup. btrfs: Use sb_want_write() to protect label change. btrfs: Use sb_want_write() to protect sysfs feature change. fs/btrfs/ctree.h| 64 +++- fs/btrfs/disk-io.c | 14 ++--- fs/btrfs/extent-tree.c | 2 +- fs/btrfs/free-space-cache.c | 2 +- fs/btrfs/inode-map.c| 5 +- fs/btrfs/super.c| 139 fs/btrfs/sysfs.c| 56 -- fs/btrfs/transaction.c | 43 ++ fs/btrfs/transaction.h | 6 +- fs/namespace.c | 36 include/linux/mount.h | 2 + 11 files changed, 169 insertions(+), 200 deletions(-) -- 2.2.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
[PATCH] Btrfs: add missing blk_finish_plug in btrfs_sync_log()
Add missing blk_finish_plug in btrfs_sync_log() Signed-off-by: Forrest Liu forre...@synology.com --- fs/btrfs/tree-log.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index a266587..06f0283 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2623,6 +2623,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, } if (log_root_tree-log_transid_committed = root_log_ctx.log_transid) { + blk_finish_plug(plug); mutex_unlock(log_root_tree-log_mutex); ret = root_log_ctx.log_ret; goto out; -- 1.9.1 -- 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