aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2012-09-26 22:21:21 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-09-26 22:21:21 -0400
commitaaf7d73e54b6915310ece11aedb19ec06a833642 (patch)
treef34ceab694382ab812423f6774e30ef4889cc400 /fs/ext4
parentb71fc079b5d8f42b2a52743c8d2f1d35d655b1c5 (diff)
ext4: enable FITRIM ioctl on bigalloc file system
With a minor tweaks regarding minimum extent size to discard and discarded bytes reporting the FITRIM can be enabled on bigalloc file system and it works without any problem. This patch fixes minlen handling and discarded bytes reporting to take into consideration bigalloc enabled file systems and finally removes the restriction and allow FITRIM to be used on file system with bigalloc feature enabled. Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/ioctl.c7
-rw-r--r--fs/ext4/mballoc.c5
2 files changed, 3 insertions, 9 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 8b84fe28ccaf..4c8174aa685c 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -404,13 +404,6 @@ resizefs_out:
404 if (!blk_queue_discard(q)) 404 if (!blk_queue_discard(q))
405 return -EOPNOTSUPP; 405 return -EOPNOTSUPP;
406 406
407 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
408 EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
409 ext4_msg(sb, KERN_ERR,
410 "FITRIM not supported with bigalloc");
411 return -EOPNOTSUPP;
412 }
413
414 if (copy_from_user(&range, (struct fstrim_range __user *)arg, 407 if (copy_from_user(&range, (struct fstrim_range __user *)arg,
415 sizeof(range))) 408 sizeof(range)))
416 return -EFAULT; 409 return -EFAULT;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 8ec6f88b7a37..a415465f97a0 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4990,7 +4990,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
4990 4990
4991 start = range->start >> sb->s_blocksize_bits; 4991 start = range->start >> sb->s_blocksize_bits;
4992 end = start + (range->len >> sb->s_blocksize_bits) - 1; 4992 end = start + (range->len >> sb->s_blocksize_bits) - 1;
4993 minlen = range->minlen >> sb->s_blocksize_bits; 4993 minlen = EXT4_NUM_B2C(EXT4_SB(sb),
4994 range->minlen >> sb->s_blocksize_bits);
4994 4995
4995 if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) || 4996 if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) ||
4996 unlikely(start >= max_blks)) 4997 unlikely(start >= max_blks))
@@ -5050,6 +5051,6 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
5050 atomic_set(&EXT4_SB(sb)->s_last_trim_minblks, minlen); 5051 atomic_set(&EXT4_SB(sb)->s_last_trim_minblks, minlen);
5051 5052
5052out: 5053out:
5053 range->len = trimmed * sb->s_blocksize; 5054 range->len = EXT4_C2B(EXT4_SB(sb), trimmed) << sb->s_blocksize_bits;
5054 return ret; 5055 return ret;
5055} 5056}