Skip to content

Commit d412df5

Browse files
Eric Whitneytytso
Eric Whitney
authored andcommitted
ext4: minor defrag code improvements
Modify the error returns for two file types that can't be defragged to more clearly communicate those restrictions to a caller. When the defrag code is applied to swap files, return -ETXTBSY, and when applied to quota files, return -EOPNOTSUPP. Move an extent tree search whose results are only occasionally required to the site always requiring them for improved efficiency. Address a few typos. Signed-off-by: Eric Whitney <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent df3cb75 commit d412df5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

fs/ext4/move_extent.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,19 +472,17 @@ mext_check_arguments(struct inode *orig_inode,
472472
if (IS_IMMUTABLE(donor_inode) || IS_APPEND(donor_inode))
473473
return -EPERM;
474474

475-
/* Ext4 move extent does not support swapfile */
475+
/* Ext4 move extent does not support swap files */
476476
if (IS_SWAPFILE(orig_inode) || IS_SWAPFILE(donor_inode)) {
477-
ext4_debug("ext4 move extent: The argument files should "
478-
"not be swapfile [ino:orig %lu, donor %lu]\n",
477+
ext4_debug("ext4 move extent: The argument files should not be swap files [ino:orig %lu, donor %lu]\n",
479478
orig_inode->i_ino, donor_inode->i_ino);
480-
return -EBUSY;
479+
return -ETXTBSY;
481480
}
482481

483482
if (ext4_is_quota_file(orig_inode) && ext4_is_quota_file(donor_inode)) {
484-
ext4_debug("ext4 move extent: The argument files should "
485-
"not be quota files [ino:orig %lu, donor %lu]\n",
483+
ext4_debug("ext4 move extent: The argument files should not be quota files [ino:orig %lu, donor %lu]\n",
486484
orig_inode->i_ino, donor_inode->i_ino);
487-
return -EBUSY;
485+
return -EOPNOTSUPP;
488486
}
489487

490488
/* Ext4 move extent supports only extent based file */
@@ -631,11 +629,11 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
631629
if (ret)
632630
goto out;
633631
ex = path[path->p_depth].p_ext;
634-
next_blk = ext4_ext_next_allocated_block(path);
635632
cur_blk = le32_to_cpu(ex->ee_block);
636633
cur_len = ext4_ext_get_actual_len(ex);
637634
/* Check hole before the start pos */
638635
if (cur_blk + cur_len - 1 < o_start) {
636+
next_blk = ext4_ext_next_allocated_block(path);
639637
if (next_blk == EXT_MAX_BLOCKS) {
640638
ret = -ENODATA;
641639
goto out;
@@ -663,7 +661,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
663661
donor_page_index = d_start >> (PAGE_SHIFT -
664662
donor_inode->i_blkbits);
665663
offset_in_page = o_start % blocks_per_page;
666-
if (cur_len > blocks_per_page- offset_in_page)
664+
if (cur_len > blocks_per_page - offset_in_page)
667665
cur_len = blocks_per_page - offset_in_page;
668666
/*
669667
* Up semaphore to avoid following problems:

0 commit comments

Comments
 (0)