From b497cd843f4ea9fb4a2a240054cf0e4b7300a9f2 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 3 Apr 2015 10:47:21 -0400 Subject: [PATCH] Fix make-fsync-to-sync-parent-dir-in-no-journal-for-real-this-time --- better-error-handling-for-kstrdup-failures | 55 ---------------------- ...ync-parent-dir-in-no-journal-for-real-this-time | 23 ++++----- series | 2 +- 3 files changed, 9 insertions(+), 71 deletions(-) delete mode 100644 better-error-handling-for-kstrdup-failures diff --git a/better-error-handling-for-kstrdup-failures b/better-error-handling-for-kstrdup-failures deleted file mode 100644 index 75cb3af0..00000000 --- a/better-error-handling-for-kstrdup-failures +++ /dev/null @@ -1,55 +0,0 @@ -ext4: better error handling for kstrdup() failures - -From: Taesoo Kim - -Upon memory pressure, kstrdup() might fail and correctly -handle memory error, although current implementation do not -refer orig_data. - -NOTE: fortunately the correct impl works, other than a corner case -where kstrdup() fails and kzalloc() succeeds; it might record 'NULL' -in the log. - -Signed-off-by: Taesoo Kim -Signed-off-by: Theodore Ts'o ---- - fs/ext4/super.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index e061e66..e2a609c 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -3408,7 +3408,7 @@ static int ext4_reserve_clusters(struct ext4_sb_info *sbi, ext4_fsblk_t count) - - static int ext4_fill_super(struct super_block *sb, void *data, int silent) - { -- char *orig_data = kstrdup(data, GFP_KERNEL); -+ char *orig_data; - struct buffer_head *bh; - struct ext4_super_block *es = NULL; - struct ext4_sb_info *sbi; -@@ -3431,6 +3431,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) - unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; - ext4_group_t first_not_zeroed; - -+ orig_data = kstrdup(data, GFP_KERNEL); -+ if (!orig_data) -+ return -ENOMEM; -+ - sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); - if (!sbi) - goto out_free_orig; -@@ -4843,6 +4847,8 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) - int i, j; - #endif - char *orig_data = kstrdup(data, GFP_KERNEL); -+ if (!orig_data) -+ return -ENOMEM; - - /* Store the original options */ - old_sb_flags = sb->s_flags; --- -2.3.3 - - diff --git a/make-fsync-to-sync-parent-dir-in-no-journal-for-real-this-time b/make-fsync-to-sync-parent-dir-in-no-journal-for-real-this-time index 6def50b7..02d1f8b4 100644 --- a/make-fsync-to-sync-parent-dir-in-no-journal-for-real-this-time +++ b/make-fsync-to-sync-parent-dir-in-no-journal-for-real-this-time @@ -32,14 +32,14 @@ Reviewed-by: Jan Kara Cc: Frank Mayhar Cc: stable@vger.kernel.org --- - fs/ext4/namei.c | 19 ++++++++++--------- - 1 file changed, 10 insertions(+), 9 deletions(-) + fs/ext4/namei.c | 20 +++++++++++--------- + 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c -index 2291923..25e1e03 100644 +index efb64ae..23a0b9b 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c -@@ -1865,7 +1865,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, +@@ -1864,7 +1864,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, struct inode *inode) { struct inode *dir = dentry->d_parent->d_inode; @@ -48,7 +48,7 @@ index 2291923..25e1e03 100644 struct ext4_dir_entry_2 *de; struct ext4_dir_entry_tail *t; struct super_block *sb; -@@ -1889,14 +1889,14 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, +@@ -1888,14 +1888,14 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, return retval; if (retval == 1) { retval = 0; @@ -65,7 +65,7 @@ index 2291923..25e1e03 100644 ext4_clear_inode_flag(dir, EXT4_INODE_INDEX); dx_fallback++; ext4_mark_inode_dirty(handle, dir); -@@ -1908,14 +1908,14 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, +@@ -1907,14 +1907,15 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, return PTR_ERR(bh); retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh); @@ -81,12 +81,13 @@ index 2291923..25e1e03 100644 - return make_indexed_dir(handle, dentry, inode, bh); + EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_DIR_INDEX)) { + retval = make_indexed_dir(handle, dentry, inode, bh); ++ bh = NULL; /* make_indexed_dir releases bh */ + goto out; + } brelse(bh); } bh = ext4_append(handle, dir, &block); -@@ -1931,6 +1931,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, +@@ -1930,6 +1931,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, } retval = add_dirent_to_buf(handle, dentry, inode, de, bh); @@ -94,11 +95,3 @@ index 2291923..25e1e03 100644 brelse(bh); if (retval == 0) ext4_set_inode_state(inode, EXT4_STATE_NEWENTRY); --- -1.8.3.1 - --- -To unsubscribe from this list: send the line "unsubscribe linux-ext4" in -the body of a message to majordomo@vger.kernel.org -More majordomo info at http://vger.kernel.org/majordomo-info.html - diff --git a/series b/series index 9dc1a584..ebd657a5 100644 --- a/series +++ b/series @@ -6,7 +6,6 @@ add-dirtytime-sysctl-tuning-knob fix-bh-leak-on-error-paths fix-transposition-typo-in-format-string fix-comments-in-ext4_can_extents_be_merged -make-fsync-to-sync-parent-dir-in-no-journal-for-real-this-time remove-unused-header-files remove-useless-condition-in-if-statement remove-block_device_ejected @@ -14,6 +13,7 @@ remove-unnecessary-lock-unlock-of-i_block_reservation_lock allocate-entire-range-in-zero-range fix-loss-of-delalloc-extent-info-in-ext4_zero_range dont-release-reserved-space-for-previously-allocated-cluster +make-fsync-to-sync-parent-dir-in-no-journal-for-real-this-time ########################################## # unstable patches -- 2.11.4.GIT