summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
Commit message (Collapse)AuthorAgeFilesLines
* btrfs: nuke write_super from commentsArtem Bityutskiy2012-08-041-4/+0Star
| | | | | | | | | | The '->write_super' superblock method is gone, and this patch removes all the references to 'write_super' from btrfs. Cc: Chris Mason <chris.mason@fusionio.com> Cc: linux-btrfs@vger.kernel.org Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* Btrfs: suppress printk() if all device I/O stats are zeroStefan Behrens2012-07-231-0/+8
| | | | | | | Code is added to suppress the I/O stats printing at mount time if all statistic values are zero. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs: remove unwanted printk() for btrfs device I/O statsStefan Behrens2012-07-231-3/+0Star
| | | | | | | | | | | | People complained about the annoying kernel log message "btrfs: no dev_stats entry found ... (OK on first mount after mkfs)" everytime a filesystem is mounted for the first time after running mkfs. Since the distribution of the btrfs-progs is not synchronized to the kernel version, mkfs like it is now will be used also in the future. Then this message is not useful to find errors, it is just annoying. This commit removes the printk(). Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs: add DEVICE_READY ioctlJosef Bacik2012-07-231-1/+8
| | | | | | | | | | This will be used in conjunction with btrfs device ready <dev>. This is needed for initrd's to have a nice and lightweight way to tell if all of the devices needed for a file system are in the cache currently. This keeps them from having to do mount+sleep loops waiting for devices to show up. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* btrfs: join DEV_STATS ioctls to oneDavid Sterba2012-07-231-3/+2Star
| | | | | | | | | | | | | | | | Commit c11d2c236cc260b36 (Btrfs: add ioctl to get and reset the device stats) introduced two ioctls doing almost the same thing distinguished by just the ioctl number which encodes "do reset after read". I have suggested http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg16604.html to implement it via the ioctl args. This hasn't happen, and I think we should use a more clean way to pass flags and should not waste ioctl numbers. CC: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs: resume balance on rw (re)mounts properlyIlya Dryomov2012-07-021-9/+27
| | | | | | | | This introduces btrfs_resume_balance_async(), which, given that restriper state was recovered earlier by btrfs_recover_balance(), resumes balance in btrfs-balance kthread. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* Btrfs: restore restriper state on all mountsIlya Dryomov2012-07-021-20/+19Star
| | | | | | | | | | Fix a bug that triggered asserts in btrfs_balance() in both normal and resume modes -- restriper state was not properly restored on read-only mounts. This factors out resuming code from btrfs_restore_balance(), which is now also called earlier in the mount sequence to avoid the problem of some early writes getting the old profile. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* Btrfs: don't count I/O statistic read errors for missing devicesStefan Behrens2012-07-021-10/+12
| | | | | | | | | | | It is normal behaviour of the low level btrfs function btrfs_map_bio() to complete a bio with -EIO if the device is missing, instead of just preventing the bio creation in an earlier step. This used to cause I/O statistic read error increments and annoying printk_ratelimited messages. This commit fixes the issue. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Reported-by: Carey Underwood <cwillu@cwillu.com>
* Btrfs: use rcu to protect device->nameJosef Bacik2012-06-151-34/+58
| | | | | | | | | | | | | | Al pointed out that we can just toss out the old name on a device and add a new one arbitrarily, so anybody who uses device->name in printk could possibly use free'd memory. Instead of adding locking around all of this he suggested doing it with RCU, so I've introduced a struct rcu_string that does just that and have gone through and protected all accesses to device->name that aren't under the uuid_mutex with rcu_read_lock(). This protects us and I will use it for dealing with removing the device that we used to mount the file system in a later patch. Thanks, Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <josef@redhat.com>
* Btrfs: read device stats on mount, write modified ones during commitStefan Behrens2012-05-301-0/+176
| | | | | | | | | | The device statistics are written into the device tree with each transaction commit. Only modified statistics are written. When a filesystem is mounted, the device statistics for each involved device are read from the device tree and used to initialize the counters. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs: add ioctl to get and reset the device statsStefan Behrens2012-05-301-0/+34
| | | | | | | An ioctl interface is added to get the device statistic counters. A second ioctl is added to atomically get and reset these counters. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs: add device counters for detected IO and checksum errorsStefan Behrens2012-05-301-2/+92
| | | | | | | | | | The goal is to detect when drives start to get an increased error rate, when drives should be replaced soon. Therefore statistic counters are added that count IO errors (read, write and flush). Additionally, the software detected errors like checksum errors and corrupted blocks are counted. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs: fix wrong error returned by adding a deviceLiu Bo2012-05-301-1/+1
| | | | | | | | | | | | | | Reproduce: $ mkfs.btrfs /dev/sdb7 $ mount /dev/sdb7 /mnt/btrfs -o ro $ btrfs dev add /dev/sdb8 /mnt/btrfs ERROR: error adding the device '/dev/sdb8' - Invalid argument Since we mount with readonly options, and /dev/sdb7 is not a seeding one, a readonly notification is preferred. Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com> Reviewed-by: Josef Bacik <josef@redhat.com>
* Btrfs: fix repair code for RAID10Jan Schmidt2012-04-271-1/+2
| | | | | | | | | btrfs_map_block sets mirror_num, so that the repair code knows eventually which device gave us the read error. For RAID10, mirror_num must be 1 or 2. Before this fix mirror_num was incorrectly related to our stripe index. Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* fs/btrfs/volumes.c: add missing free_fs_devicesJulia Lawall2012-04-181-1/+3
| | | | | | Free fs_devices as done in the error-handling code just below. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
* Btrfs: fix max chunk size check in chunk allocatorIlya Dryomov2012-04-181-2/+4
| | | | | | | | | Fix a bug, where in case we need to adjust stripe_size so that the length of the resulting chunk is less than or equal to max_chunk_size, DUP chunks turn out to be only half as big as they could be. Cc: Arne Jansen <sensille@gmx.net> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* Btrfs: fix eof while discarding extentsLiu Bo2012-04-121-2/+18
| | | | | | | | | We miscalculate the length of extents we're discarding, and it leads to an eof of device. Reported-by: Daniel Blueman <daniel@quora.org> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs: flush out and clean up any block device pages during mountChris Mason2012-03-291-0/+3
| | | | | | | | | | | | | | Btrfs puts the filesystem metadata into its own address space, and somehow the block device address space isn't getting onto disk properly before a mount. The end result is that a loop of mkfs and mounting the filesystem will sometimes find stale or incorrect data. This commit should fix it by sprinkling fdatawrites and invalidate_bdev calls around. This is a short term measure to make sure it is fixed. The block devices really should be flushed and cleaned up higher in the stack. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Merge branch 'for-chris' of git://github.com/idryomov/btrfs-unstable into ↵Chris Mason2012-03-291-39/+54
|\ | | | | | | for-linus
| * Btrfs: fix infinite loop in btrfs_shrink_device()Ilya Dryomov2012-03-271-3/+2Star
| | | | | | | | | | | | | | | | If relocate of block group 0 fails with ENOSPC we end up infinitely looping because key.offset -= 1 statement in that case brings us back to where we started. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
| * Btrfs: allow dup for data chunks in mixed modeIlya Dryomov2012-03-271-4/+9
| | | | | | | | | | | | | | Generally we don't allow dup for data, but mixed chunks are special and people seem to think this has its use cases. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
| * Btrfs: validate target profiles only if we are going to use themIlya Dryomov2012-03-271-16/+11Star
| | | | | | | | | | | | | | | | Do not run sanity checks on all target profiles unless they all will be used. This came up because alloc_profile_is_valid() is now more strict than it used to be. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
| * Btrfs: move alloc_profile_is_valid() to volumes.cIlya Dryomov2012-03-271-5/+25
| | | | | | | | | | | | | | | | | | Header file is not a good place to define functions. This also moves a call to alloc_profile_is_valid() down the stack and removes a redundant check from __btrfs_alloc_chunk() - alloc_profile_is_valid() takes it into account. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
| * Btrfs: make profile_is_valid() check more strictIlya Dryomov2012-03-271-3/+3
| | | | | | | | | | | | | | | | | | | | "0" is a valid value for an on-disk chunk profile, but it is not a valid extended profile. (We have a separate bit for single chunks in extended case) Also rename it to alloc_profile_is_valid() for clarity. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
| * Btrfs: add wrappers for working with alloc profilesIlya Dryomov2012-03-271-12/+8Star
| | | | | | | | | | | | | | Add functions to abstract the conversion between chunk and extended allocation profile formats and switch everybody to use them. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* | Merge branch 'error-handling' into for-linusChris Mason2012-03-291-46/+96
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | Conflicts: fs/btrfs/ctree.c fs/btrfs/disk-io.c fs/btrfs/extent-tree.c fs/btrfs/extent_io.c fs/btrfs/extent_io.h fs/btrfs/inode.c fs/btrfs/scrub.c Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * btrfs: replace many BUG_ONs with proper error handlingJeff Mahoney2012-03-221-27/+76
| | | | | | | | | | | | | | | | | | | | | | btrfs currently handles most errors with BUG_ON. This patch is a work-in- progress but aims to handle most errors other than internal logic errors and ENOMEM more gracefully. This iteration prevents most crashes but can run into lockups with the page lock on occasion when the timing "works out." Signed-off-by: Jeff Mahoney <jeffm@suse.com>
| * btrfs: Remove BUG_ON from __finish_chunk_alloc()Mark Fasheh2012-03-221-1/+3
| | | | | | | | | | | | | | | | btrfs_alloc_chunk() unconditionally BUGs on any error returned from __finish_chunk_alloc() so there's no need for two BUG_ON lines. Remove the one from __finish_chunk_alloc(). Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Remove BUG_ON from __btrfs_alloc_chunk()Mark Fasheh2012-03-221-1/+2
| | | | | | | | | | | | | | | | We BUG_ON() error from add_extent_mapping(), but that error looks pretty easy to bubble back up - as far as I can tell there have not been any permanent modifications to fs state at that point. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Don't BUG_ON insert errors in btrfs_alloc_dev_extent()Mark Fasheh2012-03-221-1/+3
| | | | | | | | | | | | | | | | | | The only caller of btrfs_alloc_dev_extent() is __btrfs_alloc_chunk() which already bugs on any error returned. We can remove the BUG_ON's in btrfs_alloc_dev_extent() then since __btrfs_alloc_chunk() will "catch" them anyway. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: Don't BUG_ON errors in __finish_chunk_alloc()Mark Fasheh2012-03-221-4/+6
| | | | | | | | | | | | | | | | All callers of __finish_chunk_alloc() BUG_ON() return value, so it's trivial for us to always bubble up any errors caught in __finish_chunk_alloc() to be caught there. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
| * btrfs: return void in functions without error conditionsJeff Mahoney2012-03-221-12/+6Star
| | | | | | | | Signed-off-by: Jeff Mahoney <jeffm@suse.com>
* | Btrfs: allow metadata blocks larger than the page sizeChris Mason2012-03-261-1/+1
|/ | | | | | | | | | | | | | | | A few years ago the btrfs code to support blocks lager than the page size was disabled to fix a few corner cases in the page cache handling. This fixes the code to properly support large metadata blocks again. Since current kernels will crash early and often with larger metadata blocks, this adds an incompat bit so that older kernels can't mount it. This also does away with different blocksizes for nodes and leaves. You get a single block size for all tree blocks. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Merge branch 'for-linus' of ↵Linus Torvalds2012-02-241-2/+31
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs Quoth Chris: "This is later than I wanted because I got backed up running through btrfs bugs from the Oracle QA teams. But they are all bug fixes that we've queued and tested since rc1. Nothing in particular stands out, this just reflects bug fixing and QA done in parallel by all the btrfs developers. The most user visible of these is: Btrfs: clear the extent uptodate bits during parent transid failures Because that helps deal with out of date drives (say an iscsi disk that has gone away and come back). The old code wasn't always properly retrying the other mirror for this type of failure." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (24 commits) Btrfs: fix compiler warnings on 32 bit systems Btrfs: increase the global block reserve estimates Btrfs: clear the extent uptodate bits during parent transid failures Btrfs: add extra sanity checks on the path names in btrfs_mksubvol Btrfs: make sure we update latest_bdev Btrfs: improve error handling for btrfs_insert_dir_item callers Btrfs: be less strict on finding next node in clear_extent_bit Btrfs: fix a bug on overcommit stuff Btrfs: kick out redundant stuff in convert_extent_bit Btrfs: skip states when they does not contain bits to clear Btrfs: check return value of lookup_extent_mapping() correctly Btrfs: fix deadlock on page lock when doing auto-defragment Btrfs: fix return value check of extent_io_ops btrfs: honor umask when creating subvol root btrfs: silence warning in raid array setup btrfs: fix structs where bitfields and spinlock/atomic share 8B word btrfs: delalloc for page dirtied out-of-band in fixup worker Btrfs: fix memory leak in load_free_space_cache() btrfs: don't check DUP chunks twice Btrfs: fix trim 0 bytes after a device delete ...
| * Btrfs: make sure we update latest_bdevChris Mason2012-02-231-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | When we are setting up the mount, we close all the devices that were not actually part of the metadata we found. But, we don't make sure that one of those devices wasn't fs_devices->latest_bdev, which means we can do a use after free on the one we closed. This updates latest_bdev as it goes. Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * Btrfs: check return value of lookup_extent_mapping() correctlyTsutomu Itoh2012-02-161-1/+1
| | | | | | | | | | | | This patch corrects error checking of lookup_extent_mapping(). Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
| * btrfs: silence warning in raid array setupDavid Sterba2012-02-151-0/+14
| | | | | | | | | | | | | | | | | | | | Raid array setup code creates an extent buffer in an usual way. When the PAGE_CACHE_SIZE is > super block size, the extent pages are not marked up-to-date, which triggers a WARN_ON in the following write_extent_buffer call. Add an explicit up-to-date call to silence the warning. Signed-off-by: David Sterba <dsterba@suse.cz>
* | Merge branch 'btrfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfsLinus Torvalds2012-01-181-3/+2Star
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'btrfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: btrfs: take allocation of ->tree_root into open_ctree() btrfs: let ->s_fs_info point to fs_info, not root... btrfs: consolidate failure exits in btrfs_mount() a bit btrfs: make free_fs_info() call ->kill_sb() unconditional btrfs: merge free_fs_info() calls on fill_super failures btrfs: kill pointless reassignment of ->s_fs_info in btrfs_fill_super() btrfs: make open_ctree() return int btrfs: sanitizing ->fs_info, part 5 btrfs: sanitizing ->fs_info, part 4 btrfs: sanitizing ->fs_info, part 3 btrfs: sanitizing ->fs_info, part 2 btrfs: sanitizing ->fs_info, part 1 btrfs: fix a deadlock in btrfs_scan_one_device() btrfs: fix mount/umount race btrfs: get ->kill_sb() of its own btrfs: preparation to fixing mount/umount race
| * btrfs: fix a deadlock in btrfs_scan_one_device()Al Viro2012-01-091-3/+2Star
| | | | | | | | | | | | | | | | | | | | pathname resolution under a global mutex, taken on some paths in ->mount() is a Bad Idea(tm) - think what happens if said pathname resolution triggers automount of some btrfs instance and walks into attempt to grab the same mutex. Deadlock - we are waiting for daemon to finish walking the path, daemon is waiting for us to release the mutex... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | Btrfs: use larger system chunksChris Mason2012-01-161-1/+1
| | | | | | | | | | | | | | | | system chunks by default are very small. This makes them slightly larger and also fixes the conditional checks to make sure we don't allocate a billion of them at once. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* | Merge branch 'integrity-check-patch-v2' of ↵Chris Mason2012-01-161-3/+4
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | git://btrfs.giantdisaster.de/git/btrfs into integration Conflicts: fs/btrfs/ctree.h fs/btrfs/super.c Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * | Btrfs: integrate integrity check module into btrfsStefan Behrens2011-12-211-3/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the last part of the patch series. It modifies the btrfs code to use the integrity check module if configured to do so with the define BTRFS_FS_CHECK_INTEGRITY. If this define is not set, the only effective change is that code is added that handles the mount option to activate the integrity check. If the mount option is set and the define BTRFS_FS_CHECK_INTEGRITY is not set, that code complains in the log and the mount fails with EINVAL. Add the mount option to activate the usage of the integrity check code. Add invocation of btrfs integrity check code init and cleanup function on mount and umount, respectively. Add hook to call btrfs integrity check code version of submit_bh/submit_bio. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* | Merge branch 'for-chris' of git://repo.or.cz/linux-btrfs-devel into integrationChris Mason2012-01-161-119/+66Star
|\ \ | | | | | | | | | | | | | | | | | | Conflicts: fs/btrfs/volumes.c Signed-off-by: Chris Mason <chris.mason@oracle.com>
| * | Btrfs: fix possible deadlock when opening a seed deviceLi Zefan2012-01-111-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The correct lock order is uuid_mutex -> volume_mutex -> chunk_mutex, but when we mount a filesystem which has backing seed devices, we have this lock chain: open_ctree() lock(chunk_mutex); read_chunk_tree(); read_one_dev(); open_seed_devices(); lock(uuid_mutex); and then we hit a lockdep splat. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
| * | Btrfs: simplfy calculation of stripe length for discard operationLi Zefan2012-01-111-64/+31Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For btrfs raid, while discarding a range of space, we'll need to know the start offset and length to discard for each device, and it's done in btrfs_map_block(). However the calculation is a bit complex for raid0 and raid10, so I reimplement it based on a fact that: dev1 dev2 dev3 (raid0) ----------------------------------- s0 s3 s6 s1 s4 s7 s2 s5 Each device has (total_stripes / nr_dev) stripes, or plus one. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
| * | Btrfs: don't pre-allocate btrfs bioLi Zefan2012-01-111-46/+21Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We pre-allocate a btrfs bio with fixed size, and then may re-allocate memory if we find stripes are bigger than the fixed size. But this pre-allocation is not necessary. Also we don't have to calcuate the stripe number twice. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
| * | Btrfs: don't pass a trans handle unnecessarily in volumes.cLi Zefan2012-01-111-11/+7Star
| |/ | | | | | | | | | | Some functions never use the transaction handle passed to them. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
* | Merge branch 'restriper' of git://github.com/idryomov/btrfs-unstable into ↵Chris Mason2012-01-161-39/+751
|\ \ | | | | | | | | | integration
| * | Btrfs: add balance progress reportingIlya Dryomov2012-01-161-4/+35
| | | | | | | | | | | | Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
| * | Btrfs: allow for canceling restriperIlya Dryomov2012-01-161-3/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | Implement an ioctl for canceling restriper. Currently we wait until relocation of the current block group is finished, in future this can be done by triggering a commit. Balance item is deleted and no memory about the interrupted balance is kept. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>