History

ext4: fix rename whiteout with fast commit

This patch adds rename whiteout support in fast commits. Note that the whiteout object that gets created is actually char device. Which imples, the function ext4_inode_journal_mode(struct inode *inode) would return "JOURNAL_DATA" for this inode. This has a consequence in fast commit code that it will make creation of the whiteout object a fast-commit ineligible behavior and thus will fall back to full commits. With this patch, this can be observed by running fast commits with rename whiteout and seeing the stats generated by ext4_fc_stats tracepoint as follows: ext4_fc_stats: dev 254:32 fc ineligible reasons: XATTR:0, CROSS_RENAME:0, JOURNAL_FLAG_CHANGE:0, NO_MEM:0, SWAP_BOOT:0, RESIZE:0, RENAME_DIR:0, FALLOC_RANGE:0, INODE_JOURNAL_DATA:16; num_commits:6, ineligible: 6, numblks: 3 So in short, this patch guarantees that in case of rename whiteout, we fall back to full commits. Amir mentioned that instead of creating a new whiteout object for every rename, we can create a static whiteout object with irrelevant nlink. That will make fast commits to not fall back to full commit. But until this happens, this patch will ensure correctness by falling back to full commits.

Harshad Shirwadkar committed 5 years ago

Commit 8210bb21 parent 2a4ae3b3 files · +12 −2Browse files

Unified · Split

3 files
  1. fs/ext4/ext4.h +2 −0
  2. fs/ext4/fast_commit.c +7 −2
  3. fs/ext4/namei.c +3 −0
fs/ext4/ext4.h+2−0
@@ -2794,6 +2794,8 @@ void __ext4_fc_track_link(handle_t *handle, struct inode *inode, · 2793 unmodified lines
27942794 struct dentry *dentry);
27952795 void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry);
27962796 void ext4_fc_track_link(handle_t *handle, struct dentry *dentry);
2797+void __ext4_fc_track_create(handle_t *handle, struct inode *inode,
2798+ struct dentry *dentry);
27972799 void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);
27982800 void ext4_fc_track_inode(handle_t *handle, struct inode *inode);
27992801 void ext4_fc_mark_ineligible(struct super_block *sb, int reason);
fs/ext4/fast_commit.c+7−2
@@ -513,10 +513,10 @@ void ext4_fc_track_link(handle_t *handle, struct dentry *dentry) · 512 unmodified lines
513513 __ext4_fc_track_link(handle, d_inode(dentry), dentry);
514514 }
515515
516−void ext4_fc_track_create(handle_t *handle, struct dentry *dentry)
516+void __ext4_fc_track_create(handle_t *handle, struct inode *inode,
517+ struct dentry *dentry)
517518 {
518519 struct __track_dentry_update_args args;
519− struct inode *inode = d_inode(dentry);
520520 int ret;
521521
522522 args.dentry = dentry;
@@ -527,6 +527,11 @@ void ext4_fc_track_create(handle_t *handle, struct dentry *dentry) · 4 unmodified lines
527527 trace_ext4_fc_track_create(inode, dentry, ret);
528528 }
529529
530+void ext4_fc_track_create(handle_t *handle, struct dentry *dentry)
531+{
532+ __ext4_fc_track_create(handle, d_inode(dentry), dentry);
533+}
534+
530535 /* __track_fn for inode tracking */
531536 static int __track_inode(struct inode *inode, void *arg, bool update)
532537 {
fs/ext4/namei.c+3−0
@@ -3873,6 +3873,7 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir, · 3872 unmodified lines
38733873 retval = ext4_mark_inode_dirty(handle, whiteout);
38743874 if (unlikely(retval))
38753875 goto end_rename;
3876+
38763877 }
38773878 if (!new.bh) {
38783879 retval = ext4_add_entry(handle, new.dentry, old.inode);
@@ -3946,6 +3947,8 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir, · 67 unmodified lines
39463947 ext4_fc_track_unlink(handle, new.dentry);
39473948 __ext4_fc_track_link(handle, old.inode, new.dentry);
39483949 __ext4_fc_track_unlink(handle, old.inode, old.dentry);
3950+ if (whiteout)
3951+ __ext4_fc_track_create(handle, whiteout, old.dentry);
39493952 }
39503953
39513954 if (new.inode) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t