aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2014-09-17btrfs: rw_devices shouldn't be incremented for seed fs in ↵Anand Jain1-1/+2
btrfs_rm_dev_replace_srcdev() seed fs devices don't participate as rw_device, so don't increment rw_devices when the device being handled belongs to a seed fs. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: fix memory leak when there is no more seed deviceAnand Jain1-0/+2
When we replace all the seed device in the system there is no point in just keeping the btrfs_fs_devices with out any device Signed-off-by: Anand Jain <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: update sprout seed pointer when seed fs is relinquishedAnand Jain1-0/+21
We are not updating sprout fs seed pointer when all seed device is replaced. This patch will check if all seed device has been replaced and then update the sprout pointer accordingly. Same reproducer as in the previous patch would apply here. And notice that btrfs_close_device will check if seed fs is present and spits out the error with out this patch. int btrfs_close_devices(struct btrfs_fs_devices *fs_devices) { :: seed_devices = fs_devices->seed; :: while (seed_devices) { fs_devices = seed_devices; seed_devices = fs_devices->seed; __btrfs_close_devices(fs_devices); free_fs_devices(fs_devices); } Signed-off-by: Anand Jain <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: fix rw_devices miss match after seed replaceAnand Jain1-0/+2
reproducer: reproducer: mount /dev/sdb /btrfs btrfs dev add /dev/sdc /btrfs btrfs rep start -B /dev/sdb /dev/sdd /btrfs umount /btrfs WARNING: CPU: 0 PID: 3882 at fs/btrfs/volumes.c:892 __btrfs_close_devices+0x1c8/0x200 [btrfs]() which is WARN_ON(fs_devices->rw_devices); The problem here is that we did not add one to the rw_devices when we replace the seed device with a writable device. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: replace seed device followed by unmount causes kernel WARNINGAnand Jain1-1/+7
reproducer: mount /dev/sdb /btrfs btrfs dev add /dev/sdc /btrfs btrfs rep start -B /dev/sdb /dev/sdd /btrfs umount /btrfs WARNING: CPU: 0 PID: 12661 at fs/btrfs/volumes.c:891 __btrfs_close_devices+0x1b0/0x200 [btrfs]() :: __btrfs_close_devices() :: WARN_ON(fs_devices->open_devices); After the seed device has been replaced the new target device is no more a seed device. So we need to update the device numbers in the fs_devices as pointed by the fs_info. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: Miao Xie <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed awareAnand Jain1-5/+9
There is no logical change in this patch, just a preparatory patch, so that changes can be easily reasoned. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: Drop stray check of fixup_workers creationAndrey Utkin1-1/+1
The issue was introduced in a79b7d4b3e8118f265dcb4bdf9a572c392f02708, adding allocation of extent_workers, so this stray check is surely not meant to be a check of something else. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=82021 Reported-by: Maks Naumov <[email protected]> Signed-off-by: Andrey Utkin <[email protected]> Reviewed-by: Eric Sandeen <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: make btrfs_search_forward return with nodes unlockedFilipe Manana5-15/+7
None of the uses of btrfs_search_forward() need to have the path nodes (level >= 1) read locked, only the leaf needs to be locked while the caller processes it. Therefore make it return a path with all nodes unlocked, except for the leaf. This change is motivated by the observation that during a file fsync we repeatdly call btrfs_search_forward() and process the returned leaf while upper nodes of the returned path (level >= 1) are read locked, which unnecessarily blocks other tasks that want to write to the same fs/subvol btree. Therefore instead of modifying the fsync code to unlock all nodes with level >= 1 immediately after calling btrfs_search_forward(), change btrfs_search_forward() to do it, so that it benefits all callers. Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: sysfs label interface should check for read only FSAnand Jain1-0/+3
Not sure how this escaped many eyes so far Signed-off-by: Anand Jain <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: code optimize: BTRFS_ATTR_RW could set the modeAnand Jain2-4/+5
BTRFS_ATTR_RW could set the mode and be inline with BTRFS_ATTR Signed-off-by: Anand Jain <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: code optimize: BTRFS_ATTR could handle the modeAnand Jain2-11/+14
All that uses BTRFS_ATTR want mode to be set at 0444 so just do it at the define. And few spacing alignments. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: use BTRFS_ATTR instead of btrfs_no_store()Anand Jain1-10/+3
we have BTRFS_ATTR define to create sysfs RO file, use that. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: avoid unnecessary switch of path locks to blocking modeFilipe Manana1-2/+1
If we need to cow a node, increase the write lock level and retry the tree search, there's no point of changing the node locks in our path to blocking mode, as we only waste time and unnecessarily wake up other tasks waiting on the spinning locks (just to block them again shortly after) because we release our path before repeating the tree search. Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: unlock nodes earlier when inserting items in a btreeFilipe Manana1-6/+6
In ctree.c:setup_items_for_insert(), we can unlock all nodes in our path before we process the leaf (shift items and data, adjust data offsets, etc). This allows for better btree concurrency, as we're often holding a write lock on at least the node at level 1. Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: use IS_ALIGNED() for assertion in btrfs_lookup_csums_range() for ↵Satoru Takeuchi1-2/+2
simplicity btrfs_lookup_csums_range() uses ALIGN() to check if "start" and "end + 1" are aligned to "root->sectorsize". It's better to replace these with IS_ALIGNED() for simplicity. Signed-off-by: Satoru Takeuchi <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: cleanup for btrfs workqueue tracepointsLiu Bo1-7/+0
Tracepoint trace_btrfs_normal_work_done never has an user, just cleanup it. Signed-off-by: Liu Bo <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: add work_struct information for workqueue tracepointLiu Bo1-3/+6
Kernel workqueue's tracepoints print the address of work_struct, while btrfs workqueue's tracepoints print the address of btrfs_work. We need a connection between this two, for example when debuging, we usually grep an address in the trace output. So it'd be better to also print work_struct in btrfs workqueue's tracepoint. Please note that we can only add this into those tracepoints whose work is still available in memory because we need to reference the work. Signed-off-by: Liu Bo <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: add trace for qgroup accountingMark Fasheh3-0/+61
We want this to debug qgroup changes on live systems. Signed-off-by: Mark Fasheh <[email protected]> Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: cleanup unused latest_devid and latest_trans in fs_devicesMiao Xie2-34/+11
The member variants - latest_devid and latest_trans - of fs_devices structure are set, but no one use them to do anything. so remove them. Signed-off-by: Miao Xie <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: update the comment of total_bytes and disk_total_bytes of btrfs_devieMiao Xie1-2/+2
Signed-off-by: Miao Xie <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: Fix the problem that the dirty flag of dev stats is clearedMiao Xie2-6/+20
The io error might happen during writing out the device stats, and the device stats information and dirty flag would be update at that time, but the current code didn't consider this case, just clear the dirty flag, it would cause that we forgot to write out the new device stats information. Fix it. Signed-off-by: Miao Xie <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: make the device lock and its protected data in the same cachelineMiao Xie1-13/+12
The lock in btrfs_device structure was far away from its protected data, it would make CPU load the cache line twice when we accessed them, move them together. Signed-off-by: Miao Xie <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: fix wrong generation check of super block on a seed deviceMiao Xie1-1/+5
The super block generation of the seed devices is not the same as the filesystem which sprouted from them because we don't update the super block on the seed devices when we change that new filesystem. So we should not use the generation of that new filesystem to check the super block generation on the seed devices, Fix it. Signed-off-by: Miao Xie <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: fix wrong fsid check of scrubMiao Xie1-5/+13
All the metadata in the seed devices has the same fsid as the fsid of the seed filesystem which is on the seed device, so we should check them by the current filesystem. Fix it. Signed-off-by: Miao Xie <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: wake up transaction thread from SYNC_FS ioctlDavid Sterba1-0/+6
The transaction thread may want to do more work, namely it pokes the cleaner ktread that will start processing uncleaned subvols. This can be triggered by user via the 'btrfs fi sync' command, otherwise there was a delay up to 30 seconds before the cleaner started to clean old snapshots. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: fix wrong max inline data size limitWang Shilong1-1/+1
inline data is stored from offset of @disk_bytenr in struct btrfs_file_extent_item. So substracting total size of struct btrfs_file_extent_item is wrong, fix it. Signed-off-by: Wang Shilong <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: fix off-by-one in cow_file_range_inline()Wang Shilong1-2/+2
Btrfs could still inline file data if its size is same as page size, so don't skip max value here. Signed-off-by: Wang Shilong <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: fall into nocompression codes quickly if possibleWang Shilong1-4/+1
If flag NOCOMPRESS is set which means bad compression ratio, we could avoid call cow_file_range_async() for this case earlier. Signed-off-by: Wang Shilong <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: fix wrong skipping compression for an inodeWang Shilong1-5/+20
If a file's compression ratios is bad, we will set NOCOMPRESS flag for it, and it will skip compression for that inode next time. However, if we remount fs to COMPRESS_FORCE, it still should try if we could compress pages for that inode, this patch fix wrong check for this problem. Signed-off-by: Wang Shilong <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: fix sparse warningFabian Frederick1-1/+2
Fix the following sparse warning: fs/btrfs/send.c:518:51: warning: incorrect type in argument 2 (different address spaces) fs/btrfs/send.c:518:51: expected char const [noderef] <asn:1>*<noident> fs/btrfs/send.c:518:51: got char * We can safely use (const char __user *) with set_fs(KERNEL_DS) __force added to avoid sparse-all warning: fs/btrfs/send.c:518:40: warning: cast adds address space to expression (<asn:1>) Signed-off-by: Fabian Frederick <[email protected]> Reviewed-by: Zach Brown <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: use BUG_ONHIMANGI SARAOGI1-2/+2
Use BUG_ON(x) rather than if(x) BUG(); The semantic patch that fixes this problem is as follows: // <smpl> @@ identifier x; @@ -if (x) BUG(); +BUG_ON(x); // </smpl> Signed-off-by: Himangi Saraogi <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs compression: merge inflate and deflate z_streamsSergey Senozhatsky1-70/+68
`struct workspace' used for zlib compression contains two zlib z_stream-s: `def_strm' used in zlib_compress_pages(), and `inf_strm' used in zlib_decompress/zlib_decompress_biovec(). None of these functions use `inf_strm' and `def_strm' simultaniously, meaning that for every compress/decompress operation we need only one z_stream (out of two available). `inf_strm' and `def_strm' are different in size of ->workspace. For inflate stream we vmalloc() zlib_inflate_workspacesize() bytes, for deflate stream - zlib_deflate_workspacesize() bytes. On my system zlib returns the following workspace sizes, correspondingly: 42312 and 268104 (+ guard pages). Keep only one `z_stream' in `struct workspace' and use it for both compression and decompression. Hence, instead of vmalloc() of two z_stream->worskpace-s, allocate only one of size: max(zlib_deflate_workspacesize(), zlib_inflate_workspacesize()) Reviewed-by: David Sterba <[email protected]> Signed-off-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: set error return value in btrfs_get_blocks_directFilipe Manana1-1/+3
We were returning with 0 (success) because we weren't extracting the error code from em (PTR_ERR(em)). Fix it. Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: Satoru Takeuchi <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: reduce size of struct extent_stateFilipe Manana2-18/+20
The tree field of struct extent_state was only used to figure out if an extent state was connected to an inode's io tree or not. For this we can just use the rb_node field itself. On a x86_64 system with this change the sizeof(struct extent_state) is reduced from 96 bytes down to 88 bytes, meaning that with a page size of 4096 bytes we can now store 46 extent states per page instead of 42. Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: use PTR_ERR_OR_ZEROFabian Frederick1-3/+1
replace IS_ERR/PTR_ERR Cc: Chris Mason <[email protected]> Cc: Josef Bacik <[email protected]> Cc: [email protected] Signed-off-by: Fabian Frederick <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: print btrfs specific info for some fatal error casesWang Shilong1-7/+7
Marc argued that if there are several btrfs filesystems mounted, while users even don't know which filesystem hit the corrupted errors something like generation verification failure. Since @extent_buffer structure has a member @fs_info, let's output btrfs device info. Reported-by: Marc MERLIN <[email protected]> Signed-off-by: Wang Shilong <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: fix writing data into the seed filesystemMiao Xie1-16/+36
If we mounted a seed filesystem with degraded option, and then added a new device into the seed filesystem, then we found adding device failed because of the IO failure. Steps to reproduce: # mkfs.btrfs -d raid1 -m raid1 <dev0> <dev1> # btrfstune -S 1 <dev0> # mount <dev0> -o degraded <mnt> # btrfs device add -f <dev2> <mnt> It is because the original didn't set the chunk on the seed device to be read-only if the degraded flag was set. It was introduced by patch f48b90756, which fixed the problem the raid1 filesystem became read-only after one device of it was missing. But this fix method was not right, we should set the read-only flag according to the number of the missing devices, not the degraded mount option, if the number of the missing devices is less than the max error number that the profile of the chunk tolerates, we don't set it to be read-only. Cc: Josef Bacik <[email protected]> Signed-off-by: Miao Xie <[email protected]> Reviewed-by: Liu Bo <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: make defragment work with nodatacow optionWang Shilong2-3/+42
Btrfs defragment will utilize COW feature, which means this did not work for nodatacow option, this problem was detected by xfstests generic/018 with nodatacow mount option. Fix this problem by forcing cow for a extent with state @EXTETN_DEFRAG setting. Signed-off-by: Wang Shilong <[email protected]> Signed-off-by: Miao Xie <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: label should not contain return charSatoru Takeuchi1-3/+12
Rediffed remaining parts of original patch from Anand Jain. This makes sure to avoid trailing newlines in the btrfs label output reproducer.sh: =============================================================================== TEST_DEV=/dev/vdb TEST_DIR=/home/sat/mnt umount /home/sat/mnt mkfs.btrfs -f $TEST_DEV UUID=$(btrfs fi show $TEST_DEV | head -1 | sed -e 's/.*uuid: \([-0-9a-z]*\)$/\1/') mount $TEST_DEV $TEST_DIR LABELFILE=/sys/fs/btrfs/$UUID/label echo "Test for empty label..." >&2 LINES="$(cat $LABELFILE | wc -l | awk '{print $1}')" RET=0 if [ $LINES -eq 0 ] ; then echo '[PASS] Trailing \n is removed correctly.' >&2 else echo '[FAIL] Trailing \n still exists.' >&2 RET=1 fi echo "Test for non-empty label..." >&2 echo testlabel >$LABELFILE LINES="$(cat $LABELFILE | wc -l | awk '{print $1}')" if [ $LINES -eq 1 ] ; then echo '[PASS] Trailing \n is removed correctly.' >&2 else echo '[FAIL] Trailing \n still exists.' >&2 RET=1 fi exit $RET =============================================================================== Signed-off-by: Satoru Takeuchi <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: device delete must be syslogedAnand Jain1-0/+3
as in the disk add patch, disk detached from the volume must be recorded in the syslog as well for the same reason. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: device add must be syslogedAnand Jain1-0/+3
when we add a new disk to the mounted btrfs we don't record it as of now, disk add is a critical change of btrfs configuration, it must be recorded in the syslog to help offline investigations of customer problems when reported. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17Btrfs: clear compress-force when remounting with compress optionWang Shilong1-0/+7
Steps to reproduce: # mkfs.btrfs -f /dev/sdb # mount /dev/sdb /mnt -o compress-force=lzo # mount /dev/sdb /mnt -o remount,compress=zlib # cat /proc/mounts Remounting from compress-force to compress could not clear compress-force option. The problem is there is no way for users to clear compress-force option separately. Fix this problem by clearing @FORCE_COMPRESS flag when remounting to compress=xxx. Suggested-by: Tsutomu Itoh <[email protected]> Signed-off-by: Wang Shilong <[email protected]> Reviewed-by: David Sterba <[email protected]> Reviewed-by: Satoru Takeuchi <[email protected]> Tested-by: Satoru Takeuchi <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: use DIV_ROUND_UP instead of open-coded variantsDavid Sterba8-32/+22
The form (value + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT is equivalent to (value + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE The rest is a simple subsitution, no difference in the generated assembly code. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: clean away stripe_align helperDavid Sterba1-10/+1
Only wraps the ALIGN macro. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: use nodesize everywhere, kill leafsizeDavid Sterba15-141/+89
The nodesize and leafsize were never of different values. Unify the usage and make nodesize the one. Cleanup the redundant checks and helpers. Shaves a few bytes from .text: text data bss dec hex filename 852418 24560 23112 900090 dbbfa btrfs.ko.before 851074 24584 23112 898770 db6d2 btrfs.ko.after Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: kill the key type accessor helpersDavid Sterba17-60/+60
btrfs_set_key_type and btrfs_key_type are used inconsistently along with open coded variants. Other members of btrfs_key are accessed directly without any helpers anyway. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: make close_ctree return voidDavid Sterba3-11/+3
There's no user of the return value and we can get rid of the comment in put_super. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: cleanup ino cache members of btrfs_rootDavid Sterba5-52/+52
The naming is confusing, generic yet used for a specific cache. Add a prefix 'ino_' or rename appropriately. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: clenaup: don't call btrfs_release_path before free_pathDavid Sterba1-1/+0
Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-09-17btrfs: remove obsolete comment in btrfs_clean_one_deleted_snapshotDavid Sterba1-4/+1
The comment applied when there was a BUG_ON. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>