Skip to content

Commit 2729cfd

Browse files
harshadjstytso
authored andcommitted
ext4: use ext4_journal_start/stop for fast commit transactions
This patch drops all calls to ext4_fc_start_update() and ext4_fc_stop_update(). To ensure that there are no ongoing journal updates during fast commit, we also make jbd2_fc_begin_commit() lock journal for updates. This way we don't have to maintain two different transaction start stop APIs for fast commit and full commit. This patch doesn't remove the functions altogether since in future we want to have inode level locking for fast commits. Signed-off-by: Harshad Shirwadkar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 960e0ab commit 2729cfd

File tree

6 files changed

+4
-24
lines changed

6 files changed

+4
-24
lines changed

fs/ext4/acl.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ ext4_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
246246
handle = ext4_journal_start(inode, EXT4_HT_XATTR, credits);
247247
if (IS_ERR(handle))
248248
return PTR_ERR(handle);
249-
ext4_fc_start_update(inode);
250249

251250
if ((type == ACL_TYPE_ACCESS) && acl) {
252251
error = posix_acl_update_mode(mnt_userns, inode, &mode, &acl);
@@ -264,7 +263,6 @@ ext4_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
264263
}
265264
out_stop:
266265
ext4_journal_stop(handle);
267-
ext4_fc_stop_update(inode);
268266
if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
269267
goto retry;
270268
return error;

fs/ext4/extents.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4697,8 +4697,6 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
46974697
FALLOC_FL_INSERT_RANGE))
46984698
return -EOPNOTSUPP;
46994699

4700-
ext4_fc_start_update(inode);
4701-
47024700
if (mode & FALLOC_FL_PUNCH_HOLE) {
47034701
ret = ext4_punch_hole(inode, offset, len);
47044702
goto exit;
@@ -4762,7 +4760,6 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
47624760
inode_unlock(inode);
47634761
trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
47644762
exit:
4765-
ext4_fc_stop_update(inode);
47664763
return ret;
47674764
}
47684765

fs/ext4/file.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ static ssize_t ext4_buffered_write_iter(struct kiocb *iocb,
259259
if (iocb->ki_flags & IOCB_NOWAIT)
260260
return -EOPNOTSUPP;
261261

262-
ext4_fc_start_update(inode);
263262
inode_lock(inode);
264263
ret = ext4_write_checks(iocb, from);
265264
if (ret <= 0)
@@ -271,7 +270,6 @@ static ssize_t ext4_buffered_write_iter(struct kiocb *iocb,
271270

272271
out:
273272
inode_unlock(inode);
274-
ext4_fc_stop_update(inode);
275273
if (likely(ret > 0)) {
276274
iocb->ki_pos += ret;
277275
ret = generic_write_sync(iocb, ret);
@@ -552,9 +550,7 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
552550
goto out;
553551
}
554552

555-
ext4_fc_start_update(inode);
556553
ret = ext4_orphan_add(handle, inode);
557-
ext4_fc_stop_update(inode);
558554
if (ret) {
559555
ext4_journal_stop(handle);
560556
goto out;

fs/ext4/inode.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5320,7 +5320,7 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
53205320
if (error)
53215321
return error;
53225322
}
5323-
ext4_fc_start_update(inode);
5323+
53245324
if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
53255325
(ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
53265326
handle_t *handle;
@@ -5344,7 +5344,6 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
53445344

53455345
if (error) {
53465346
ext4_journal_stop(handle);
5347-
ext4_fc_stop_update(inode);
53485347
return error;
53495348
}
53505349
/* Update corresponding info in inode so that everything is in
@@ -5356,7 +5355,6 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
53565355
error = ext4_mark_inode_dirty(handle, inode);
53575356
ext4_journal_stop(handle);
53585357
if (unlikely(error)) {
5359-
ext4_fc_stop_update(inode);
53605358
return error;
53615359
}
53625360
}
@@ -5370,12 +5368,10 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
53705368
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
53715369

53725370
if (attr->ia_size > sbi->s_bitmap_maxbytes) {
5373-
ext4_fc_stop_update(inode);
53745371
return -EFBIG;
53755372
}
53765373
}
53775374
if (!S_ISREG(inode->i_mode)) {
5378-
ext4_fc_stop_update(inode);
53795375
return -EINVAL;
53805376
}
53815377

@@ -5499,7 +5495,6 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
54995495
ext4_std_error(inode->i_sb, error);
55005496
if (!error)
55015497
error = rc;
5502-
ext4_fc_stop_update(inode);
55035498
return error;
55045499
}
55055500

fs/ext4/ioctl.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,6 @@ int ext4_fileattr_set(struct user_namespace *mnt_userns,
743743
u32 flags = fa->flags;
744744
int err = -EOPNOTSUPP;
745745

746-
ext4_fc_start_update(inode);
747746
if (flags & ~EXT4_FL_USER_VISIBLE)
748747
goto out;
749748

@@ -764,7 +763,6 @@ int ext4_fileattr_set(struct user_namespace *mnt_userns,
764763
goto out;
765764
err = ext4_ioctl_setproject(inode, fa->fsx_projid);
766765
out:
767-
ext4_fc_stop_update(inode);
768766
return err;
769767
}
770768

@@ -1273,13 +1271,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
12731271

12741272
long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
12751273
{
1276-
long ret;
1277-
1278-
ext4_fc_start_update(file_inode(filp));
1279-
ret = __ext4_ioctl(filp, cmd, arg);
1280-
ext4_fc_stop_update(file_inode(filp));
1281-
1282-
return ret;
1274+
return __ext4_ioctl(filp, cmd, arg);
12831275
}
12841276

12851277
#ifdef CONFIG_COMPAT

fs/jbd2/journal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ int jbd2_fc_begin_commit(journal_t *journal, tid_t tid)
757757
}
758758
journal->j_flags |= JBD2_FAST_COMMIT_ONGOING;
759759
write_unlock(&journal->j_state_lock);
760+
jbd2_journal_lock_updates(journal);
760761

761762
return 0;
762763
}
@@ -768,6 +769,7 @@ EXPORT_SYMBOL(jbd2_fc_begin_commit);
768769
*/
769770
static int __jbd2_fc_end_commit(journal_t *journal, tid_t tid, bool fallback)
770771
{
772+
jbd2_journal_unlock_updates(journal);
771773
if (journal->j_fc_cleanup_callback)
772774
journal->j_fc_cleanup_callback(journal, 0);
773775
write_lock(&journal->j_state_lock);

0 commit comments

Comments
 (0)