Re: [PATCH, RFC -V2 4/4] ext4: Avoid group preallocation for closed files
From: Aneesh Kumar K.V <hidden>
Date: 2009-08-20 06:40:58
On Sun, Aug 09, 2009 at 11:23:55PM -0400, Theodore Ts'o wrote: ....
quoted hunk ↗ jump to hunk
static inline void ext4_unlock_group(struct super_block *sb,diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index a103cb0..6c7be0d 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c@@ -4191,9 +4191,17 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) return; size = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len; - isize = i_size_read(ac->ac_inode) >> bsbits; + isize = (i_size_read(ac->ac_inode) + ac->ac_sb->s_blocksize - 1) + >> bsbits; size = max(size, isize); + if ((size == isize) &&
What is this check supposed to help us ?. This would also imply we disable prealloc
only if we are allocating the last chunk in the file. Why not just
if (atomic_read(&ac->ac_inode->i_writecount) == 0) && !ext4_fs_is_busy(sbi) {
ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC;
}
+ ext4_fs_is_busy(sbi) &&
+ (atomic_read(&ac->ac_inode->i_writecount) == 0)) {
+ ac->ac_flags |= EXT4_MB_HINT_NOPREALLOC;
+ return;
+ }shouldn't it be !ext4_fs_is_busy(sbi) ?. Can you also write function documentation for ext4_fs_is_busy. I found in confusing that you are decrementing s_lock_busy if we are going to spin on spin_lock.
+
/* don't use group allocation for large files */
if (size >= sbi->s_mb_stream_request) {
ac->ac_flags |= EXT4_MB_STREAM_ALLOC;
-- -aneesh