aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/sysfs.c
AgeCommit message (Collapse)AuthorFilesLines
2015-05-27Btrfs: sysfs: separate device kobject and its attribute creationAnand Jain1-6/+15
Separate device kobject and its attribute creation so that device kobject can be created from the device discovery thread. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2015-05-27Btrfs: sysfs: let default_attrs be separate from the ksetAnand Jain1-4/+8
As of now btrfs_attrs are provided using the default_attrs through the kset. Separate them and create the default_attrs using the sysfs_create_files instead. By doing this we will have the flexibility that device discovery thread could create fsid kobject. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2015-05-27Btrfs: sysfs: introduce function btrfs_sysfs_add_fsid() to create sysfs fsidAnand Jain1-1/+14
We need it in a seperate function so that it can be called from the device discovery thread as well. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2015-05-27Btrfs: sysfs: rename __btrfs_sysfs_remove_one to btrfs_sysfs_remove_fsidAnand Jain1-4/+4
Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2015-05-27Btrfs: sysfs: reorder the kobject creationsAnand Jain1-10/+13
As of now the order in which the kobjects are created at btrfs_sysfs_add_one() is.. fsid features unknown features (dynamic features) devices. Since we would move fsid and device kobject to fs_devices from fs_info structure, this patch will reorder in which the kobjects are created as below. fsid devices features unknown features (dynamic features) And hence the btrfs_sysfs_remove_one() will follow the same in reverse order. and the device kobject destroy now can be moved into the function __btrfs_sysfs_remove_one() Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2015-05-27Btrfc: sysfs: fix, check if device_dir_kobj is init before destroyAnand Jain1-4/+6
Since the failure code in the btrfs_sysfs_add_one() can call btrfs_sysfs_remove_one() even before device_dir_kobj has been created we need to check if its null. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2015-05-27Btrfs: sysfs: fix, kobject pointer clean up needed after kobject releaseAnand Jain1-0/+1
The sysfs clean up self test like in the below code fails, since fs_info->device_dir_kobject still points to its stale kobject. Reseting this pointer will help to fix this. open_ctree() { ret = btrfs_sysfs_add_one(fs_info); :: + btrfs_sysfs_remove_one(fs_info); + ret = btrfs_sysfs_add_one(fs_info); + if (ret) { + pr_err("BTRFS: failed to init sysfs interface: %d\n", ret); + goto fail_block_groups; + } Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2015-05-27Btrfs: sysfs: fix, undo sysfs device linksAnand Jain1-0/+17
Theoritically need to remove the device links attributes, but since its entire device kobject was removed, so there wasn't any issue of about it. Just do it nicely. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2015-05-27Btrfs: sysfs: fix, btrfs_release_super_kobj() should to clean up the kobject ↵Anand Jain1-0/+2
data The following test case fails indicating that, thread tried to init an initialized object. kernel: [232104.016513] kobject (ffff880006c1c980): tried to init an initialized object, something is seriously wrong. btrfs_sysfs_remove_one() self test code: open_tree() { :: ret = btrfs_sysfs_add_one(fs_info); if (ret) { pr_err("BTRFS: failed to init sysfs interface: %d\n", ret); goto fail_block_groups; } + btrfs_sysfs_remove_one(fs_info); + ret = btrfs_sysfs_add_one(fs_info); + if (ret) { + pr_err("BTRFS: failed to init sysfs interface: %d\n", ret); + goto fail_block_groups; + } cleaning up the unregistered kobject fixes this. Signed-off-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
2015-02-16btrfs: constify structs with op functions or static definitionsDavid Sterba1-1/+1
There are some op tables that can be easily made const, similarly the sysfs feature and raid tables. This is motivated by PaX CONSTIFY plugin. Signed-off-by: David Sterba <[email protected]>
2015-02-02Btrfs: add missing cleanup on sysfs init failureFilipe Manana1-1/+9
If we failed during initialization of sysfs, we weren't unregistering the top level btrfs sysfs entry nor the debugfs stuff. Not unregistering the top level sysfs entry makes future attempts to reload the btrfs module impossible and the following is reported in dmesg: [ 2246.451296] WARNING: CPU: 3 PID: 10999 at fs/sysfs/dir.c:486 sysfs_warn_dup+0x91/0xb0() [ 2246.451298] sysfs: cannot create duplicate filename '/fs/btrfs' [ 2246.451298] Modules linked in: btrfs(+) raid6_pq xor bnep rfcomm bluetooth binfmt_misc nfsd auth_rpcgss oid_registry nfs_acl nfs lockd fscache sunrpc parport_pc parport psmouse serio_raw pcspkr evbug i2c_piix4 e1000 floppy [last unloaded: btrfs] [ 2246.451310] CPU: 3 PID: 10999 Comm: modprobe Tainted: G W 3.13.0-fdm-btrfs-next-24+ #7 [ 2246.451311] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 2246.451312] 0000000000000009 ffff8800d353fa08 ffffffff816f1da6 0000000000000410 [ 2246.451314] ffff8800d353fa58 ffff8800d353fa48 ffffffff8104a32c ffff88020821a290 [ 2246.451316] ffff88020821a290 ffff88020821a290 ffff8802148f0000 ffff8800d353fb80 [ 2246.451318] Call Trace: [ 2246.451322] [<ffffffff816f1da6>] dump_stack+0x4e/0x68 [ 2246.451324] [<ffffffff8104a32c>] warn_slowpath_common+0x8c/0xc0 [ 2246.451325] [<ffffffff8104a416>] warn_slowpath_fmt+0x46/0x50 [ 2246.451328] [<ffffffff81367dc5>] ? strlcat+0x65/0x90 (....) This fixes the following change: btrfs: add simple debugfs interface commit 1bae30982bc86ab66d61ccb6e22792593b45d44d Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-11-12btrfs: move commit out of sysfs when changing labelDavid Sterba1-13/+8
Signed-off-by: David Sterba <[email protected]>
2014-11-12btrfs: move commit out of sysfs when changing featuresDavid Sterba1-8/+5
Signed-off-by: David Sterba <[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 Jain1-1/+1
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 Jain1-7/+7
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: 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-08-21Btrfs: fix regression of btrfs device replaceLiu Bo1-1/+1
Commit 49c6f736f34f901117c20960ebd7d5e60f12fcac( btrfs: dev replace should replace the sysfs entry) added the missing sysfs entry in the process of device replace, but didn't take missing devices into account, so now we have BUG: unable to handle kernel NULL pointer dereference at 0000000000000088 IP: [<ffffffffa0268551>] btrfs_kobj_rm_device+0x21/0x40 [btrfs] ... To reproduce it, 1. mkfs.btrfs -f disk1 disk2 2. mkfs.ext4 disk1 3. mount disk2 /mnt -odegraded 4. btrfs replace start -B 1 disk3 /mnt -------------------------- This fixes the problem. Reported-by: Chris Murphy <[email protected]> Signed-off-by: Liu Bo <[email protected]> Reviewed-by: Satoru Takeuchi <[email protected]> Tested-by: Satoru Takeuchi <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-06-28btrfs: dev add should add its sysfs entryAnand Jain1-3/+9
we would need the device links to be created, when device is added. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-06-28btrfs: dev delete should remove sysfs entryAnand Jain1-0/+20
when we delete the device from the mounted btrfs, we would need its corresponding sysfs enty to be removed as well. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-06-28btrfs: rename add_device_membership to btrfs_kobj_add_deviceAnand Jain1-2/+2
Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-06-09btrfs: allocate raid type kobjects dynamicallyJeff Mahoney1-2/+3
We are currently allocating space_info objects in an array when we allocate space_info. When a user does something like: # btrfs balance start -mconvert=raid1 -dconvert=raid1 /mnt # btrfs balance start -mconvert=single -dconvert=single /mnt -f # btrfs balance start -mconvert=raid1 -dconvert=raid1 / We can end up with memory corruption since the kobject hasn't been reinitialized properly and the name pointer was left set. The rationale behind allocating them statically was to avoid creating a separate kobject container that just contained the raid type. It used the index in the array to determine the index. Ultimately, though, this wastes more memory than it saves in all but the most complex scenarios and introduces kobject lifetime questions. This patch allocates the kobjects dynamically instead. Note that we also remove the kobject_get/put of the parent kobject since kobject_add and kobject_del do that internally. Signed-off-by: Jeff Mahoney <[email protected]> Reported-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-06-09btrfs: usage error should not be logged into system logAnand Jain1-4/+1
I have an opinion that system logs /var/log/messages are valuable info to investigate the real system issues at the data center. People handling data center issues do spend a lot time and efforts analyzing messages files. Having usage error logged into /var/log/messages is something we should avoid. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-06-09btrfs: export more from FS_INFO to sysfsDavid Sterba1-0/+40
Similar to the FS_INFO updates, export the basic filesystem info through sysfs: node size, sector size and clone alignment. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-03-10btrfs: add simple debugfs interfaceDavid Sterba1-6/+27
Help during debugging to export various interesting infromation and tunables without the need of extra mount options or ioctls. Usage: * declare your variable in sysfs.h, and include where you need it * define the variable in sysfs.c and make it visible via debugfs_create_TYPE Depends on CONFIG_DEBUG_FS. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Josef Bacik <[email protected]>
2014-02-15btrfs: fix null pointer deference at btrfs_sysfs_add_one+0x105Anand Jain1-2/+8
bdev is null when disk has disappeared and mounted with the degrade option stack trace --------- btrfs_sysfs_add_one+0x105/0x1c0 [btrfs] open_ctree+0x15f3/0x1fe0 [btrfs] btrfs_mount+0x5db/0x790 [btrfs] ? alloc_pages_current+0xa4/0x160 mount_fs+0x34/0x1b0 vfs_kern_mount+0x62/0xf0 do_mount+0x22e/0xa80 ? __get_free_pages+0x9/0x40 ? copy_mount_options+0x31/0x170 SyS_mount+0x7e/0xc0 system_call_fastpath+0x16/0x1b --------- reproducer: ------- mkfs.btrfs -draid1 -mraid1 /dev/sdc /dev/sdd (detach a disk) devmgt detach /dev/sdc [1] mount -o degrade /dev/sdd /btrfs ------- [1] github.com/anajain/devmgt.git Signed-off-by: Anand Jain <[email protected]> Tested-by: Hidetoshi Seto <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: sysfs: list the NO_HOLES featureDavid Sterba1-0/+2
Signed-off-by: David Sterba <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: sysfs: don't show reserved incompat featureDavid Sterba1-2/+0
The COMPRESS_LZOv2 incompat featue is currently not implemented, the bit is only reserved, no point to list it in sysfs. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28Btrfs: convert printk to btrfs_ and fix BTRFS prefixFrank Holton1-1/+1
Convert all applicable cases of printk and pr_* to the btrfs_* macros. Fix all uses of the BTRFS prefix. Signed-off-by: Frank Holton <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: fix leaks during sysfs teardownJeff Mahoney1-60/+73
Filipe noticed that we were leaking the features attribute group after umount. His fix of just calling sysfs_remove_group() wasn't enough since that removes just the supported features and not the unsupported features. This patch changes the unknown feature handling to add them individually so we can skip the kmalloc and uses the same iteration to tear them down later. We also fix the error handling during mount so that we catch the failing creation of the per-super kobject, and handle proper teardown of a half-setup sysfs context. Tested properly with kmemleak enabled this time. Reported-by: Filipe David Borba Manana <[email protected]> Signed-off-by: Jeff Mahoney <[email protected]> Tested-by: Filipe David Borba Manana <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: replace BUG in can_modify_featureDavid Sterba1-1/+3
We don't need to crash hard here, it's just reading a sysfs file. The values considered in switch are from a fixed set, the default case should not happen at all. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: reserve no transaction units in btrfs_feature_attr_storeDavid Sterba1-1/+1
Added in patch "btrfs: add ability to change features via sysfs", modifications to superblock don't need to reserve metadata blocks when starting a transaction. Signed-off-by: David Sterba <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: publish fs label in sysfsJeff Mahoney1-0/+44
This adds a writeable attribute which describes the label. Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: publish device membership in sysfsJeff Mahoney1-0/+32
Now that we have the infrastructure for per-super attributes, we can publish device membership in /sys/fs/btrfs/<fsid>/devices. The information is published as symlinks to the block devices. Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: publish allocation data in sysfsJeff Mahoney1-0/+148
While trying to debug ENOSPC issues, it's helpful to understand what the kernel's view of the available space is. We export this information via ioctl, but sysfs files are more easily used. Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: use feature attribute names to print better error messagesJeff Mahoney1-1/+32
Now that we have the feature name strings available in the kernel via the sysfs attributes, we can use them for printing better failure messages from the ioctl path. Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: add ability to change features via sysfsJeff Mahoney1-3/+115
This patch adds the ability to change (set/clear) features while the file system is mounted. A bitmask is added for each feature set for the support to set and clear the bits. A message indicating which bit has been set or cleared is issued when it's been changed and also when permission or support for a particular bit has been denied. Since the the attributes can now be writable, we need to introduce another struct attribute to hold the different permissions. If neither set or clear is supported, the file will have 0444 permissions. If either set or clear is supported, the file will have 0644 permissions and the store handler will filter out the write based on the bitmask. Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: publish unknown feature bits in sysfsJeff Mahoney1-1/+107
With the compat and compat-ro bits, it's possible for file systems to exist that have features that aren't supported by the kernel's file system implementation yet still be mountable. This patch publishes read-only info on those features using a prefix:number format, where the number is the bit number rather than the shifted value. e.g. "compat:12" Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: publish per-super features in sysfsJeff Mahoney1-16/+65
This patch publishes information on which features are enabled in the file system on a per-super basis. At this point, it only publishes information on features supported by the file system implementation. Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: publish per-super attributes in sysfsJeff Mahoney1-0/+36
This patch adds per-super attributes to sysfs. It doesn't publish any attributes yet, but does the proper lifetime handling as well as the basic infrastructure to add new attributes. Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2014-01-28btrfs: publish supported featured in sysfsJeff Mahoney1-0/+44
This patch adds the ability to publish supported features to sysfs under /sys/fs/btrfs/features. The files are module-wide and export which features the kernel supports. The content, for now, is just "0\n". Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2013-03-01btrfs: fixup/remove module.h usage as requiredPaul Gortmaker1-1/+0
We want to avoid module.h where posible, since it in turn includes nearly all of header space. This means removing it where it is not required, and using export.h where we are only exporting symbols via EXPORT_SYMBOL and friends. Signed-off-by: Paul Gortmaker <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2011-06-17btrfs: Remove unused sysfs codeMaarten Lankhorst1-146/+0
Removes code no longer used. The sysfs file itself is kept, because the btrfs developers expressed interest in putting new entries to sysfs. Signed-off-by: Maarten Lankhorst <[email protected]> Signed-off-by: Chris Mason <[email protected]>
2011-05-22Merge branch 'cleanups' of git://repo.or.cz/linux-2.6/btrfs-unstable into ↵Chris Mason1-77/+0
inode_numbers Conflicts: fs/btrfs/extent-tree.c fs/btrfs/free-space-cache.c fs/btrfs/inode.c fs/btrfs/tree-log.c Signed-off-by: Chris Mason <[email protected]>
2011-05-06btrfs: remove all unused functionsDavid Sterba1-65/+0
Remove static and global declarations and/or definitions. Reduces size of btrfs.ko by ~3.4kB. text data bss dec hex filename 402081 7464 200 409745 64091 btrfs.ko.base 398620 7144 200 405964 631cc btrfs.ko.remove-all Signed-off-by: David Sterba <[email protected]>
2010-03-07Driver core: Constify struct sysfs_ops in struct kobj_typeEmese Revfy1-2/+2
Constify struct sysfs_ops. This is part of the ops structure constification effort started by Arjan van de Ven et al. Benefits of this constification: * prevents modification of data that is shared (referenced) by many other structure instances at runtime * detects/prevents accidental (but not intentional) modification attempts on archs that enforce read-only kernel data at runtime * potentially better optimized code as the compiler can assume that the const data cannot be changed * the compiler/linker move const data into .rodata and therefore exclude them from false sharing Signed-off-by: Emese Revfy <[email protected]> Acked-by: David Teigland <[email protected]> Acked-by: Matt Domsch <[email protected]> Acked-by: Maciej Sosnowski <[email protected]> Acked-by: Hans J. Koch <[email protected]> Acked-by: Pekka Enberg <[email protected]> Acked-by: Jens Axboe <[email protected]> Acked-by: Stephen Hemminger <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2009-01-05Btrfs: Fix checkpatch.pl warningsChris Mason1-2/+4
There were many, most are fixed now. struct-funcs.c generates some warnings but these are bogus. Signed-off-by: Chris Mason <[email protected]>
2009-01-05Btrfs: do not call kfree if kmalloc failed in btrfs_sysfs_add_superShen Feng1-2/+1
Signed-off-by: Shen Feng <[email protected]>
2008-09-25Remove Btrfs compat code for older kernelsChris Mason1-33/+0
Btrfs had compatibility code for kernels back to 2.6.18. These have been removed, and will be maintained in a separate backport git tree from now on. Signed-off-by: Chris Mason <[email protected]>