summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'cleanups/for-4.4' of ↵Chris Mason2015-10-2216-211/+220
|\ | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.4
| * btrfs: reada: Fix returned errno codeLuis de Bethencourt2015-10-211-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | reada is using -1 instead of the -ENOMEM defined macro to specify that a buffer allocation failed. Since the error number is propagated, the caller will get a -EPERM which is the wrong error condition. Also, updating the caller to return the exact value from reada_add_block. Smatch tool warning: reada_add_block() warn: returning -1 instead of -ENOMEM is sloppy Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: check-integrity: Fix returned errno codesLuis de Bethencourt2015-10-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | check-integrity is using -1 instead of the -ENOMEM defined macro to specify that a buffer allocation failed. Since the error number is propagated, the caller will get a -EPERM which is the wrong error condition. Also, the smatch tool complains with the following warnings: btrfsic_process_superblock() warn: returning -1 instead of -ENOMEM is sloppy btrfsic_read_block() warn: returning -1 instead of -ENOMEM is sloppy Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: compress: put variables defined per compress type in struct to make ↵Byongho Lee2015-10-211-46/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cache friendly Below variables are defined per compress type. - struct list_head comp_idle_workspace[BTRFS_COMPRESS_TYPES] - spinlock_t comp_workspace_lock[BTRFS_COMPRESS_TYPES] - int comp_num_workspace[BTRFS_COMPRESS_TYPES] - atomic_t comp_alloc_workspace[BTRFS_COMPRESS_TYPES] - wait_queue_head_t comp_workspace_wait[BTRFS_COMPRESS_TYPES] BTW, while accessing one compress type of these variables, the next or before address is other compress types of it. So this patch puts these variables in a struct to make cache friendly. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: cleanup iterating over prop_handlers arrayByongho Lee2015-10-211-7/+6
| | | | | | | | | | | | | | | | | | | | | | This patch eliminates the last item of prop_handlers array which is used to check end of array and instead uses ARRAY_SIZE macro. Though this is a very tiny optimization, using ARRAY_SIZE macro is a good practice to iterate array. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: fix a comment typoGeliang Tang2015-10-211-1/+1
| | | | | | | | | | | | | | | | Just fix a typo in the code comment. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: declare rsv_count as unsigned int instead of intAlexandru Moise2015-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | rsv_count ultimately gets passed to start_transaction() which now takes an unsigned int as its num_items parameter. The value of rsv_count should always be positive so declare it as being unsigned. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: change num_items type from u64 to unsigned intAlexandru Moise2015-10-212-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | The value of num_items that start_transaction() ultimately always takes is a small one, so a 64 bit integer is overkill. Also change num_items for btrfs_start_transaction() and btrfs_start_transaction_lflush() as well. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: cleanup btrfs_balance profile validity checksAlexandru Moise2015-10-211-9/+12
| | | | | | | | | | | | | | | | Improve readability by generalizing the profile validity checks. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs/file.c: remove an unsed varialbe first_indexShan Hai2015-10-211-3/+0
| | | | | | | | | | | | | | | | | | The commit b37392ea86761 ("Btrfs: cleanup unnecessary parameter and variant of prepare_pages()") makes it redundant. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Shan Hai <haishan.bai@hotmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: use btrfs_raid_array in btrfs_reduce_alloc_profileZhao Lei2015-10-211-26/+22
| | | | | | | | | | | | | | | | | | | | | | | | btrfs_raid_array[] holds attributes of all raid types. Use btrfs_raid_array[].devs_min is best way for request in btrfs_reduce_alloc_profile(), instead of use complex condition of each raid types. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: use btrfs_raid_array for btrfs_get_num_tolerated_disk_barrier_failures()Zhao Lei2015-10-213-13/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | btrfs_raid_array[] is used to define all raid attributes, use it to get tolerated_failures in btrfs_get_num_tolerated_disk_barrier_failures(), instead of complex condition in function. It can make code simple and auto-support other possible raid-type in future. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Move btrfs_raid_array to publicZhao Lei2015-10-212-59/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This array is used to record attributes of each raid type, make it public, and many functions will benifit with this array. For example, num_tolerated_disk_barrier_failures(), we can avoid complex conditions in this function, and get raid attribute simply by accessing above array. It can also make code logic simple, reduce duplication code, and increase maintainability. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: use a single if() statement for one outcome in get_block_rsv()Alexandru Moise2015-10-211-7/+3
| | | | | | | | | | | | | | | | | | Rather than have three separate if() statements for the same outcome we should just OR them together in the same if() statement. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: memset cur_trans->delayed_refs to zeroAlexandru Moise2015-10-211-6/+2
| | | | | | | | | | | | | | | | | | Use memset() to null out the btrfs_delayed_ref_root of btrfs_transaction instead of setting all the members to 0 by hand. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: remove unnecessary list_delByongho Lee2015-10-211-1/+0
| | | | | | | | | | | | | | | | | | We can safely iterate whole list items, without using list_del macro. So remove the list_del call. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: replace unnecessary list_for_each_entry_safe to list_for_each_entryByongho Lee2015-10-211-2/+1
| | | | | | | | | | | | | | | | | | There is no removing list element while iterating over list. So, replace list_for_each_entry_safe to list_for_each_entry. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: trimming some start_transaction() code awayAlexandru Moise2015-10-211-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Just call kmem_cache_zalloc() instead of calling kmem_cache_alloc(). We're just initializing most fields to 0, false and NULL later on _anyway_, so to make the code mode readable and potentially gain a bit of performance (completely untested claim), we should fill our btrfs_trans_handle with zeros on allocation then just initialize those five remaining fields (not counting the list_heads) as normal. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Fixed declaration of old_lenAlexandru Moise2015-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | old_len is used to store the return value of btrfs_item_size_nr(). The return value of btrfs_item_size_nr() is of type u32. To improve code correctness and avoid mixing signed and unsigned integers I've changed old_len to be of type u32 as well. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * btrfs: Fixed dsize and last_off declarationsAlexandru Moise2015-10-211-2/+2
| | | | | | | | | | | | | | | | | | | | The return values of btrfs_item_offset_nr and btrfs_item_size_nr are of type u32. To avoid mixing signed and unsigned integers we should also declare dsize and last_off to be of type u32. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * Btrfs: btrfs_submit_bio_hook: Use btrfs_wq_endio_type values instead of ↵Chandan Rajendra2015-10-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | integer constants btrfs_submit_bio_hook() uses integer constants instead of values from "enum btrfs_wq_endio_type". Fix this. Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Signed-off-by: David Sterba <dsterba@suse.com>
* | Merge branch 'fix/waitqueue-barriers' of ↵Chris Mason2015-10-1312-7/+62
|\ \ | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.4
| * | btrfs: comment the rest of implicit barriers before waitqueue_activeDavid Sterba2015-10-105-0/+22
| | | | | | | | | | | | | | | | | | | | | There are atomic operations that imply the barrier for waitqueue_active mixed in an if-condition. Signed-off-by: David Sterba <dsterba@suse.com>
| * | btrfs: remove extra barrier before waitqueue_activeDavid Sterba2015-10-101-2/+6
| | | | | | | | | | | | | | | | | | | | | Removing barriers is scary, but a call to atomic_dec_and_test implies a barrier, so we don't need to issue another one. Signed-off-by: David Sterba <dsterba@suse.com>
| * | btrfs: add comments to barriers before waitqueue_activeDavid Sterba2015-10-105-2/+16
| | | | | | | | | | | | | | | | | | Reduce number of undocumented barriers out there. Signed-off-by: David Sterba <dsterba@suse.com>
| * | btrfs: comment waitqueue_active implied by locksDavid Sterba2015-10-102-1/+11
| | | | | | | | | | | | | | | Suggested-by: Chris Mason <clm@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | btrfs: add barrier for waitqueue_active in clear_btree_io_treeDavid Sterba2015-10-101-0/+6
| | | | | | | | | | | | | | | | | | | | | waitqueue_active should be preceded by a barrier, in this function we don't need to call it all the time. Signed-off-by: David Sterba <dsterba@suse.com>
| * | btrfs: remove waitqueue_active check from btrfs_rm_dev_replace_unblockedDavid Sterba2015-10-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Normally the waitqueue_active would need a barrier, but this is not necessary here because it's not a performance sensitive context and we can call wake_up directly. Suggested-by: Chris Mason <clm@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* | | Merge branch 'anand/sysfs-updates-v4.3-rc3' of ↵Chris Mason2015-10-1317-177/+198
|\ \ \ | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.4 Signed-off-by: Chris Mason <clm@fb.com>
| * | | Btrfs: move kobj stuff out of dev_replace lock rangeLiu Bo2015-10-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid deadlock described in commit 084b6e7c7607 ("btrfs: Fix a lockdep warning when running xfstest."), we should move kobj stuff out of dev_replace lock range. "It is because the btrfs_kobj_{add/rm}_device() will call memory allocation with GFP_KERNEL, which may flush fs page cache to free space, waiting for it self to do the commit, causing the deadlock. To solve the problem, move btrfs_kobj_{add/rm}_device() out of the dev_replace lock range, also involing split the btrfs_rm_dev_replace_srcdev() function into remove and free parts. Now only btrfs_rm_dev_replace_remove_srcdev() is called in dev_replace lock range, and kobj_{add/rm} and btrfs_rm_dev_replace_free_srcdev() are called out of the lock range." Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> [added lockup description] Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: add helper for closing one deviceAnand Jain2015-10-012-30/+37
| | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> [reworded subject and changelog] Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: don't log error from btrfs_get_bdev_and_sbAnand Jain2015-10-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally the message was not in a helper but ended up there. We should print error messages from callers instead. Signed-off-by: Anand Jain <anand.jain@oracle.com> [reworded subject and changelog] Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: kernel operation should come after user input has been verifiedAnand Jain2015-10-011-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By general rule of thumb there shouldn't be any way that user land could trigger a kernel operation just by sending wrong arguments. Here do commit cleanups after user input has been verified. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: enhance btrfs_scratch_superblock to scratch all superblocksAnand Jain2015-10-012-13/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch updates and renames btrfs_scratch_superblocks, (which is used by the replace device thread), with those fixes from the scratch superblock code section of btrfs_rm_device(). The fixes are: Scratch all copies of superblock Notify kobject that superblock has been changed Update time on the device So that btrfs_rm_device() can use the function btrfs_scratch_superblocks() instead of its own scratch code. And further replace deivce code which similarly releases device back to the system, will have the fixes from the btrfs device delete. Signed-off-by: Anand Jain <anand.jain@oracle.com> [renamed to btrfs_scratch_superblock] Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: add btrfs_read_dev_one_super() to read one specific SBAnand Jain2015-10-012-20/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This uses a chunk of code from btrfs_read_dev_super() and creates a function called btrfs_read_dev_one_super() so that next patch can use it for scratch superblock. Signed-off-by: Anand Jain <anand.jain@oracle.com> [renamed bufhead to bh] Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: use BTRFS_ERROR_DEV_MISSING_NOT_FOUND when missing device is not foundAnand Jain2015-10-011-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use btrfs specific error code BTRFS_ERROR_DEV_MISSING_NOT_FOUND instead of -ENOENT. Next this removes the logging when user specifies "missing" and we don't find it in the kernel device list. Logging are for system events not for user input errors. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: consolidate btrfs_error() to btrfs_std_error()Anand Jain2015-09-2911-33/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | btrfs_error() and btrfs_std_error() does the same thing and calls _btrfs_std_error(), so consolidate them together. And the main motivation is that btrfs_error() is closely named with btrfs_err(), one handles error action the other is to log the error, so don't closely name them. Signed-off-by: Anand Jain <anand.jain@oracle.com> Suggested-by: David Sterba <dsterba@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: __btrfs_std_error() logic should be consistent w/out CONFIG_PRINTK ↵Anand Jain2015-09-291-22/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | defined error handling logic behaves differently with or without CONFIG_PRINTK defined, since there are two copies of the same function which a bit of different logic One, when CONFIG_PRINTK is defined, code is __btrfs_std_error(..) { :: save_error_info(fs_info); if (sb->s_flags & MS_BORN) btrfs_handle_error(fs_info); } and two when CONFIG_PRINTK is not defined, the code is __btrfs_std_error(..) { :: if (sb->s_flags & MS_BORN) { save_error_info(fs_info); btrfs_handle_error(fs_info); } } I doubt if this was intentional ? and appear to have caused since we maintain two copies of the same function and they got diverged with commits. Now to decide which logic is correct reviewed changes as below, 533574c6bc30cf526cc1c41bde050c854a945efb Commit added two copies of this function cf79ffb5b79e8a2b587fbf218809e691bb396c98 Commit made change to only one copy of the function and to the copy when CONFIG_PRINTK is defined. To fix this, instead of maintaining two copies of same function approach, maintain single function, and just put the extra portion of the code under CONFIG_PRINTK define. This patch just does that. And keeps code of with CONFIG_PRINTK defined. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: SB read failure should return EIO for __bread failureAnand Jain2015-09-292-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will return EIO when __bread() fails to read SB, instead of EINVAL. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: rename super_kobj to fsid_kobjAnand Jain2015-09-293-20/+20
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: rename btrfs_kobj_rm_device to btrfs_sysfs_rm_device_linkAnand Jain2015-09-294-8/+8
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: rename btrfs_kobj_add_device to btrfs_sysfs_add_device_linkAnand Jain2015-09-294-5/+5
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: rename btrfs_sysfs_remove_one to btrfs_sysfs_remove_mountedAnand Jain2015-09-293-5/+5
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
| * | | Btrfs: rename btrfs_sysfs_add_one to btrfs_sysfs_add_mountedAnand Jain2015-09-293-3/+3
| |/ / | | | | | | | | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* | | Merge branch 'cleanup/messages' of ↵Chris Mason2015-10-1313-97/+187
|\ \ \ | |_|/ |/| | | | | git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.4
| * | btrfs: switch more printks to our helpersDavid Sterba2015-10-086-21/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | Convert the simple cases, not all functions provide a way to reach the fs_info. Also skipped debugging messages (print-tree, integrity checker and pr_debug) and messages that are printed from possibly unfinished mount. Signed-off-by: David Sterba <dsterba@suse.com>
| * | btrfs: switch message printers to ratelimited variantsDavid Sterba2015-10-086-33/+31
| | | | | | | | | | | | Signed-off-by: David Sterba <dsterba@suse.com>
| * | btrfs: introduce ratelimited variants of message printing functionsDavid Sterba2015-10-081-0/+21
| | | | | | | | | | | | Signed-off-by: David Sterba <dsterba@suse.com>
| * | btrfs: switch message printers to ratelimited _in_rcu variantsDavid Sterba2015-10-084-16/+16
| | | | | | | | | | | | Signed-off-by: David Sterba <dsterba@suse.com>
| * | btrfs: introduce ratelimited _in_rcu variants of message printing functionsDavid Sterba2015-10-081-0/+38
| | | | | | | | | | | | Signed-off-by: David Sterba <dsterba@suse.com>