Commit 0a52d108 authored by David Sterba's avatar David Sterba

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: default avatarDavid Sterba <dsterba@suse.com>
parent 63e727ec
...@@ -1273,14 +1273,14 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, ...@@ -1273,14 +1273,14 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
extent_thresh = SZ_256K; extent_thresh = SZ_256K;
/* /*
* if we were not given a file, allocate a readahead * If we were not given a file, allocate a readahead context. As
* context * readahead is just an optimization, defrag will work without it so
* we don't error out.
*/ */
if (!file) { if (!file) {
ra = kzalloc(sizeof(*ra), GFP_KERNEL); ra = kzalloc(sizeof(*ra), GFP_KERNEL);
if (!ra) if (ra)
return -ENOMEM; file_ra_state_init(ra, inode->i_mapping);
file_ra_state_init(ra, inode->i_mapping);
} else { } else {
ra = &file->f_ra; ra = &file->f_ra;
} }
...@@ -1363,8 +1363,9 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, ...@@ -1363,8 +1363,9 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
if (i + cluster > ra_index) { if (i + cluster > ra_index) {
ra_index = max(i, ra_index); ra_index = max(i, ra_index);
btrfs_force_ra(inode->i_mapping, ra, file, ra_index, if (ra)
cluster); btrfs_force_ra(inode->i_mapping, ra, file,
ra_index, cluster);
ra_index += cluster; ra_index += cluster;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment