diff options
author | David Sterba <dsterba@suse.com> | 2017-06-22 03:22:58 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-08-16 16:12:03 +0200 |
commit | 0a52d108089f337ce20d74bf53f2e574c8ee43f2 (patch) | |
tree | c9927b31a2bcda6ba85ea564f4d1748f9d07a7a1 /fs/btrfs | |
parent | 63e727ecd238be2281156f2f0d5d7ad593d14ee8 (diff) | |
download | linux-0a52d108089f337ce20d74bf53f2e574c8ee43f2.tar.bz2 |
btrfs: defrag: make readahead state allocation failure non-fatal
All sorts of readahead errors are not considered fatal. We can continue
defragmentation without it, with some potential slow down, which will
last only for the current inode.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ioctl.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 4d1b07b81549..496e873b14de 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1273,14 +1273,14 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, extent_thresh = SZ_256K; /* - * if we were not given a file, allocate a readahead - * context + * If we were not given a file, allocate a readahead context. As + * readahead is just an optimization, defrag will work without it so + * we don't error out. */ if (!file) { ra = kzalloc(sizeof(*ra), GFP_KERNEL); - if (!ra) - return -ENOMEM; - file_ra_state_init(ra, inode->i_mapping); + if (ra) + file_ra_state_init(ra, inode->i_mapping); } else { ra = &file->f_ra; } @@ -1363,8 +1363,9 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, if (i + cluster > ra_index) { ra_index = max(i, ra_index); - btrfs_force_ra(inode->i_mapping, ra, file, ra_index, - cluster); + if (ra) + btrfs_force_ra(inode->i_mapping, ra, file, + ra_index, cluster); ra_index += cluster; } |