Skip to contentSkip to conversation

ldiskfs patches against 5.2-rc2+

RFC PATCH New James Simmons 6 participants 53 messages Jul 22, 2019 – Aug 5, 2019 1 message not in the archive ext4 file system

lore
Share & tools
lore
#0 lore raw

cover ldiskfs patches against 5.2-rc2+

From: James Simmons <[email protected]>

With the work of Shaun Tancheff from Cray to bring the ldiskfs patches in sync with the kernel in Neil's kernel source tree it was a easy port from OpenSFS to the kernel proper. This is just to start the discussion on how to move forward main streaming what Lustre has done with ext4. So let the flames begin!!!!

James Simmons (22):
ext4: add i_fs_version
ext4: use d_find_alias() in ext4_lookup
ext4: prealloc table optimization
ext4: export inode management
ext4: various misc changes
ext4: add extra checks for mballoc
ext4: update .. for hash indexed directory
ext4: kill off struct dx_root
ext4: fix mballoc pa free mismatch
ext4: add data in dentry feature
ext4: over ride current_time
ext4: add htree lock implementation
ext4: Add a proc interface for max_dir_size.
ext4: remove inode_lock handling
ext4: remove bitmap corruption warnings
ext4: add warning for directory htree growth
ext4: optimize ext4_journal_callback_add
ext4: attach jinode in writepages
ext4: don't check before replay
ext4: use GFP_NOFS in ext4_inode_attach_jinode
ext4: export ext4_orphan_add
ext4: export mb stream allocator variables

 fs/ext4/Makefile     |   4 +-
 fs/ext4/balloc.c     |  11 +-
 fs/ext4/dir.c        |  14 +-
 fs/ext4/ext4.h       | 225 +++++++++++-
 fs/ext4/ext4_jbd2.c  |   4 +
 fs/ext4/ext4_jbd2.h  |   2 +-
 fs/ext4/hash.c       |   1 +
 fs/ext4/htree_lock.c | 891 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/htree_lock.h | 187 ++++++++++
 fs/ext4/ialloc.c     |  10 +-
 fs/ext4/inline.c     |  16 +-
 fs/ext4/inode.c      |  24 +-
 fs/ext4/mballoc.c    | 479 +++++++++++++++++++------
 fs/ext4/mballoc.h    |   4 +-
 fs/ext4/namei.c      | 978 +++++++++++++++++++++++++++++++++++++++++++--------
 fs/ext4/super.c      |  27 +-
 fs/ext4/sysfs.c      |  20 +-
 17 files changed, 2601 insertions(+), 296 deletions(-)
 create mode 100644 fs/ext4/htree_lock.c
 create mode 100644 fs/ext4/htree_lock.h
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/22 ext4: add i_fs_version

From: James Simmons <[email protected]>

Add inode version field that osd-ldiskfs uses.

---
 fs/ext4/ext4.h   | 2 ++
 fs/ext4/ialloc.c | 1 +
 fs/ext4/inode.c  | 4 ++--
 3 files changed, 5 insertions(+), 2 deletions(-)
fs/ext4/ext4.h +2 -0
index 1cb6785..8abbcab 100644
@@ -1063,6 +1063,8 @@ struct ext4_inode_info {
 	struct dquot *i_dquot[MAXQUOTAS];
 #endif
 
+	u64 i_fs_version;
+
 	/* Precomputed uuid+inum+igen checksum for seeding inode checksums */
 	__u32 i_csum_seed;
 
fs/ext4/ialloc.c +1 -0
index 764ff4c..09ae4a4 100644
@@ -1100,6 +1100,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
 	ei->i_dtime = 0;
 	ei->i_block_group = group;
 	ei->i_last_alloc_group = ~0;
+	ei->i_fs_version = 0;
 
 	ext4_set_inode_flags(inode);
 	if (IS_DIRSYNC(inode))
fs/ext4/inode.c +2 -2
index c7f77c6..6e66175 100644
@@ -4806,14 +4806,14 @@ static inline void ext4_inode_set_iversion_queried(struct inode *inode, u64 val)
 	if (unlikely(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
 		inode_set_iversion_raw(inode, val);
 	else
-		inode_set_iversion_queried(inode, val);
+		EXT4_I(inode)->i_fs_version = val;
 }
 static inline u64 ext4_inode_peek_iversion(const struct inode *inode)
 {
 	if (unlikely(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
 		return inode_peek_iversion_raw(inode);
 	else
-		return inode_peek_iversion(inode);
+		return EXT4_I(inode)->i_fs_version;
 }
 
 struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 1/22 ext4: add i_fs_version

Quoted 3 lines · James Simmons

From: James Simmons <[email protected]>

Add inode version field that osd-ldiskfs uses.

We need more words here. What is i_fs_version used for?

(I'll probably find out as I keep reading, but I need to know
the intention first, or I cannot properly review the patches that make use of it.
)
NeilBrown

Quoted 56 lines
---
 fs/ext4/ext4.h   | 2 ++
 fs/ext4/ialloc.c | 1 +
 fs/ext4/inode.c  | 4 ++--
 3 files changed, 5 insertions(+), 2 deletions(-)
fs/ext4/ext4.h +2 -0
index 1cb6785..8abbcab 100644
@@ -1063,6 +1063,8 @@ struct ext4_inode_info {
 	struct dquot *i_dquot[MAXQUOTAS];
 #endif
 
+	u64 i_fs_version;
+
 	/* Precomputed uuid+inum+igen checksum for seeding inode checksums */
 	__u32 i_csum_seed;
 
fs/ext4/ialloc.c +1 -0
index 764ff4c..09ae4a4 100644
@@ -1100,6 +1100,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
 	ei->i_dtime = 0;
 	ei->i_block_group = group;
 	ei->i_last_alloc_group = ~0;
+	ei->i_fs_version = 0;
 
 	ext4_set_inode_flags(inode);
 	if (IS_DIRSYNC(inode))
fs/ext4/inode.c +2 -2
index c7f77c6..6e66175 100644
@@ -4806,14 +4806,14 @@ static inline void ext4_inode_set_iversion_queried(struct inode *inode, u64 val)
 	if (unlikely(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
 		inode_set_iversion_raw(inode, val);
 	else
-		inode_set_iversion_queried(inode, val);
+		EXT4_I(inode)->i_fs_version = val;
 }
 static inline u64 ext4_inode_peek_iversion(const struct inode *inode)
 {
 	if (unlikely(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
 		return inode_peek_iversion_raw(inode);
 	else
-		return inode_peek_iversion(inode);
+		return EXT4_I(inode)->i_fs_version;
 }
 
 struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/4860f6d8/attachment.sig>

#3 lore raw

PATCH 1/22 ext4: add i_fs_version

Quoted 11 lines
Quoted 4 lines

From: James Simmons <[email protected]>

Add inode version field that osd-ldiskfs uses.

We need more words here. What is i_fs_version used for?

(I'll probably find out as I keep reading, but I need to know
the intention first, or I cannot properly review the patches that make use of it.
)

Sadly these patches don't contain much in terms of why they exist. I did some digging and it seems at one time Lustre did use the i_version field directly for it recovery process. It seems ext4 stomps on its i_version independently of lustre so it can't be trusted in use of recovery.

Quoted 60 lines

NeilBrown

Quoted 56 lines
---
 fs/ext4/ext4.h   | 2 ++
 fs/ext4/ialloc.c | 1 +
 fs/ext4/inode.c  | 4 ++--
 3 files changed, 5 insertions(+), 2 deletions(-)
fs/ext4/ext4.h +2 -0
index 1cb6785..8abbcab 100644
@@ -1063,6 +1063,8 @@ struct ext4_inode_info {
 	struct dquot *i_dquot[MAXQUOTAS];
 #endif
 
+	u64 i_fs_version;
+
 	/* Precomputed uuid+inum+igen checksum for seeding inode checksums */
 	__u32 i_csum_seed;
 
fs/ext4/ialloc.c +1 -0
index 764ff4c..09ae4a4 100644
@@ -1100,6 +1100,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
 	ei->i_dtime = 0;
 	ei->i_block_group = group;
 	ei->i_last_alloc_group = ~0;
+	ei->i_fs_version = 0;
 
 	ext4_set_inode_flags(inode);
 	if (IS_DIRSYNC(inode))
fs/ext4/inode.c +2 -2
index c7f77c6..6e66175 100644
@@ -4806,14 +4806,14 @@ static inline void ext4_inode_set_iversion_queried(struct inode *inode, u64 val)
 	if (unlikely(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
 		inode_set_iversion_raw(inode, val);
 	else
-		inode_set_iversion_queried(inode, val);
+		EXT4_I(inode)->i_fs_version = val;
 }
 static inline u64 ext4_inode_peek_iversion(const struct inode *inode)
 {
 	if (unlikely(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
 		return inode_peek_iversion_raw(inode);
 	else
-		return inode_peek_iversion(inode);
+		return EXT4_I(inode)->i_fs_version;
 }
 
 struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 1/22 ext4: add i_fs_version

In reply to NeilBrown
Quoted 5 lines · NeilBrown
Quoted 2 lines · James Simmons

From: James Simmons <[email protected]>

Quoted 7 lines
Quoted 1 line

Add inode version field that osd-ldiskfs uses.

We need more words here. What is i_fs_version used for?

(I'll probably find out as I keep reading, but I need to know the intention first, or I cannot properly review the patches that make use of it.

We use the 64-bit i_version field to store the Lustre transno in which the inode was last modified. This maintains the NFS required semantics that the version change when the inode is modified, but the number has a specific meaning so we don't want the ext4 code or VFS to just increment it.

When a client modifies an inode, the old version is returned in the RPC reply to the client. The old version number can be used during Lustre recovery (RPC replay using "Version Based Recovery", VBR) after an MDS crash to determine if it is safe to apply this change to the inode, in the case that some clients have been evicted and we don't have a full stream of RPCs to replay.

If we could get some way to prevent the kernel from updating the inode->i_version (which is now also a 64-bit value) then we could remove one more patch from our code. In the meantime, the current kernel is not conducive to hijacking inode->i_version so we need to store our own value in the ext4_inode_info and write that to disk instead of the kernel version.

Cheers, Andreas

Quoted 54 lines
Quoted 54 lines

---

fs/ext4/ext4.h   | 2 ++
fs/ext4/ialloc.c | 1 +
fs/ext4/inode.c  | 4 ++--
3 files changed, 5 insertions(+), 2 deletions(-)
fs/ext4/ext4.h +2 -0
index 1cb6785..8abbcab 100644
@@ -1063,6 +1063,8 @@ struct ext4_inode_info {
 	struct dquot *i_dquot[MAXQUOTAS];
 #endif
 
+	u64 i_fs_version;
+
 	/* Precomputed uuid+inum+igen checksum for seeding inode checksums */
 	__u32 i_csum_seed;
 
fs/ext4/ialloc.c +1 -0
index 764ff4c..09ae4a4 100644
@@ -1100,6 +1100,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
 	ei->i_dtime = 0;
 	ei->i_block_group = group;
 	ei->i_last_alloc_group = ~0;
+	ei->i_fs_version = 0;
 
 	ext4_set_inode_flags(inode);
 	if (IS_DIRSYNC(inode))
fs/ext4/inode.c +2 -2
index c7f77c6..6e66175 100644
@@ -4806,14 +4806,14 @@ static inline void ext4_inode_set_iversion_queried(struct inode *inode, u64 val)
 	if (unlikely(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
 		inode_set_iversion_raw(inode, val);
 	else
-		inode_set_iversion_queried(inode, val);
+		EXT4_I(inode)->i_fs_version = val;
 }
 static inline u64 ext4_inode_peek_iversion(const struct inode *inode)
 {
 	if (unlikely(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
 		return inode_peek_iversion_raw(inode);
 	else
-		return inode_peek_iversion(inode);
+		return EXT4_I(inode)->i_fs_version;
 }
 
Quoted 3 lines
Quoted 3 lines
fs/ext4/inode.c +0 -0
 struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
Signature · 1 line
1.8.3.1

Cheers, Andreas
--
Andreas Dilger
Principal Lustre Architect
Whamcloud

#5 lore raw

PATCH 2/22 ext4: use d_find_alias() in ext4_lookup

In reply to James Simmons

From: James Simmons <[email protected]>

Really old bug that might not even exist anymore?

---
 fs/ext4/namei.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
fs/ext4/namei.c +29 -0
index cd01c4a..a616f58 100644
@@ -1664,6 +1664,35 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
 		}
 	}
 
+	/* ".." shouldn't go into dcache to preserve dcache hierarchy
+	 * otherwise we'll get parent being a child of actual child.
+	 * see bug 10458 for details -bzzz
+	 */
+	if (inode && (dentry->d_name.name[0] == '.' &&
+		      (dentry->d_name.len == 1 || (dentry->d_name.len == 2 &&
+						   dentry->d_name.name[1] == '.')))) {
+		struct dentry *goal = NULL;
+
+		/* first, look for an existing dentry - any one is good */
+		goal = d_find_any_alias(inode);
+		if (!goal) {
+			spin_lock(&dentry->d_lock);
+			/* there is no alias, we need to make current dentry:
+			 *  a) inaccessible for __d_lookup()
+			 *  b) inaccessible for iopen
+			 */
+			J_ASSERT(hlist_unhashed(&dentry->d_u.d_alias));
+			dentry->d_flags |= DCACHE_NFSFS_RENAMED;
+			/* this is d_instantiate() ... */
+			hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
+			dentry->d_inode = inode;
+			spin_unlock(&dentry->d_lock);
+		}
+		if (goal)
+			iput(inode);
+		return goal;
+	}
+
 #ifdef CONFIG_UNICODE
 	if (!inode && IS_CASEFOLDED(dir)) {
 		/* Eventually we want to call d_add_ci(dentry, NULL)
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 2/22 ext4: use d_find_alias() in ext4_lookup

Quoted 3 lines · James Simmons

From: James Simmons <[email protected]>

Really old bug that might not even exist anymore?

If there is a bug, it is somewhere else. ext4_lookup() should never be called on "." or "..". Whatever calls ext4_lookup must filter those out if there are a possibility.

NeilBrown

Quoted 48 lines
---
 fs/ext4/namei.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
fs/ext4/namei.c +29 -0
index cd01c4a..a616f58 100644
@@ -1664,6 +1664,35 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
 		}
 	}
 
+	/* ".." shouldn't go into dcache to preserve dcache hierarchy
+	 * otherwise we'll get parent being a child of actual child.
+	 * see bug 10458 for details -bzzz
+	 */
+	if (inode && (dentry->d_name.name[0] == '.' &&
+		      (dentry->d_name.len == 1 || (dentry->d_name.len == 2 &&
+						   dentry->d_name.name[1] == '.')))) {
+		struct dentry *goal = NULL;
+
+		/* first, look for an existing dentry - any one is good */
+		goal = d_find_any_alias(inode);
+		if (!goal) {
+			spin_lock(&dentry->d_lock);
+			/* there is no alias, we need to make current dentry:
+			 *  a) inaccessible for __d_lookup()
+			 *  b) inaccessible for iopen
+			 */
+			J_ASSERT(hlist_unhashed(&dentry->d_u.d_alias));
+			dentry->d_flags |= DCACHE_NFSFS_RENAMED;
+			/* this is d_instantiate() ... */
+			hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
+			dentry->d_inode = inode;
+			spin_unlock(&dentry->d_lock);
+		}
+		if (goal)
+			iput(inode);
+		return goal;
+	}
+
 #ifdef CONFIG_UNICODE
 	if (!inode && IS_CASEFOLDED(dir)) {
 		/* Eventually we want to call d_add_ci(dentry, NULL)
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/502da634/attachment-0001.sig>

#7 lore raw

PATCH 3/22 ext4: prealloc table optimization

In reply to James Simmons

Optimize prealloc table

---
 fs/ext4/ext4.h    |   7 +-
 fs/ext4/inode.c   |   3 +
 fs/ext4/mballoc.c | 221 +++++++++++++++++++++++++++++++++++++++++-------------
 fs/ext4/namei.c   |   4 +-
 fs/ext4/sysfs.c   |   8 +-
 5 files changed, 186 insertions(+), 57 deletions(-)
fs/ext4/ext4.h +6 -1
index 8abbcab..423ab4d 100644
@@ -1190,6 +1190,8 @@ struct ext4_inode_info {
 /* Metadata checksum algorithm codes */
 #define EXT4_CRC32C_CHKSUM		1
 
+#define EXT4_MAX_PREALLOC_TABLE		64
+
 /*
  * Structure of the super block
  */
@@ -1447,12 +1449,14 @@ struct ext4_sb_info {
 
 	/* tunables */
 	unsigned long s_stripe;
-	unsigned int s_mb_stream_request;
+	unsigned long s_mb_small_req;
+	unsigned long s_mb_large_req;
 	unsigned int s_mb_max_to_scan;
 	unsigned int s_mb_min_to_scan;
 	unsigned int s_mb_stats;
 	unsigned int s_mb_order2_reqs;
 	unsigned int s_mb_group_prealloc;
+	unsigned long *s_mb_prealloc_table;
 	unsigned int s_max_dir_size_kb;
 	/* where last allocation was done - for stream allocation */
 	unsigned long s_mb_last_group;
@@ -2457,6 +2461,7 @@ extern int ext4_init_inode_table(struct super_block *sb,
 extern void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate);
 
 /* mballoc.c */
+extern const struct file_operations ext4_seq_prealloc_table_fops;
 extern const struct seq_operations ext4_mb_seq_groups_ops;
 extern long ext4_mb_stats;
 extern long ext4_mb_max_to_scan;
fs/ext4/inode.c +3 -0
index 6e66175..c37418a 100644
@@ -2796,6 +2796,9 @@ static int ext4_writepages(struct address_space *mapping,
 		ext4_journal_stop(handle);
 	}
 
+	if (wbc->nr_to_write < sbi->s_mb_small_req)
+		wbc->nr_to_write = sbi->s_mb_small_req;
+
 	if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
 		range_whole = 1;
 
fs/ext4/mballoc.c +169 -52

293 lines not on this page · raw message

fs/ext4/namei.c +2 -2
index a616f58..a52b311 100644
@@ -752,8 +752,8 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
 	if (root->info.hash_version != DX_HASH_TEA &&
 	    root->info.hash_version != DX_HASH_HALF_MD4 &&
 	    root->info.hash_version != DX_HASH_LEGACY) {
-		ext4_warning_inode(dir, "Unrecognised inode hash code %u",
-				   root->info.hash_version);
+		ext4_warning_inode(dir, "Unrecognised inode hash code %u for directory %lu",
+				   root->info.hash_version, dir->i_ino);
 		goto fail;
 	}
 	if (fname)
fs/ext4/sysfs.c +6 -2
index 04b4f53..1375815 100644
@@ -184,7 +184,8 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
 EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
 EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs);
-EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request);
+EXT4_RW_ATTR_SBI_UI(mb_small_req, s_mb_small_req);
+EXT4_RW_ATTR_SBI_UI(mb_large_req, s_mb_large_req);
 EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc);
 EXT4_RW_ATTR_SBI_UI(extent_max_zeroout_kb, s_extent_max_zeroout_kb);
 EXT4_ATTR(trigger_fs_error, 0200, trigger_test_error);
@@ -213,7 +214,8 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 	ATTR_LIST(mb_max_to_scan),
 	ATTR_LIST(mb_min_to_scan),
 	ATTR_LIST(mb_order2_req),
-	ATTR_LIST(mb_stream_req),
+	ATTR_LIST(mb_small_req),
+	ATTR_LIST(mb_large_req),
 	ATTR_LIST(mb_group_prealloc),
 	ATTR_LIST(max_writeback_mb_bump),
 	ATTR_LIST(extent_max_zeroout_kb),
@@ -413,6 +415,8 @@ int ext4_register_sysfs(struct super_block *sb)
 				sb);
 		proc_create_seq_data("mb_groups", S_IRUGO, sbi->s_proc,
 				&ext4_mb_seq_groups_ops, sb);
+		proc_create_data("prealloc_table", S_IRUGO, sbi->s_proc,
+				 &ext4_seq_prealloc_table_fops, sb);
 	}
 	return 0;
 }
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 3/22 ext4: prealloc table optimization

Quoted 1 line · James Simmons

Optimize prealloc table

"Optimize"??? What does that even mean here?

I notice that the patch removes a comment:

/* XXX: should this table be tunable? */

and at least some of what the patch does is to make that table tunable. There should be a patch which *only* makes that table tunable, with hopefully a suggestion of why this is a good thing, and then anything else need to go in a separate patch (with text telling me why this is an improvement).

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/70240ba3/attachment.sig>

#9 lore raw

PATCH 3/22 ext4: prealloc table optimization

In reply to James Simmons

Hello,

I am glad to see LU-12335 patch is integrated here.

Best regards,
Artem Blagodarenko.

?On 22/07/2019, 04:24, "James Simmons" <[email protected]> wrote:

    Optimize prealloc table
    
    Signed-off-by: James Simmons <[email protected]>
    ---
     fs/ext4/ext4.h    |   7 +-
     fs/ext4/inode.c   |   3 +
     fs/ext4/mballoc.c | 221 +++++++++++++++++++++++++++++++++++++++++-------------
     fs/ext4/namei.c   |   4 +-
     fs/ext4/sysfs.c   |   8 +-
     5 files changed, 186 insertions(+), 57 deletions(-)
    
    diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
    index 8abbcab..423ab4d 100644
    --- a/fs/ext4/ext4.h
    +++ b/fs/ext4/ext4.h
    @@ -1190,6 +1190,8 @@ struct ext4_inode_info {
     /* Metadata checksum algorithm codes */
     #define EXT4_CRC32C_CHKSUM		1
     
    +#define EXT4_MAX_PREALLOC_TABLE		64
    +
     /*
      * Structure of the super block
      */
    @@ -1447,12 +1449,14 @@ struct ext4_sb_info {
     
     	/* tunables */
     	unsigned long s_stripe;
    -	unsigned int s_mb_stream_request;
    +	unsigned long s_mb_small_req;
    +	unsigned long s_mb_large_req;
     	unsigned int s_mb_max_to_scan;
     	unsigned int s_mb_min_to_scan;
     	unsigned int s_mb_stats;
     	unsigned int s_mb_order2_reqs;
     	unsigned int s_mb_group_prealloc;
    +	unsigned long *s_mb_prealloc_table;
     	unsigned int s_max_dir_size_kb;
     	/* where last allocation was done - for stream allocation */
     	unsigned long s_mb_last_group;
    @@ -2457,6 +2461,7 @@ extern int ext4_init_inode_table(struct super_block *sb,
     extern void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate);
     
     /* mballoc.c */
    +extern const struct file_operations ext4_seq_prealloc_table_fops;
     extern const struct seq_operations ext4_mb_seq_groups_ops;
     extern long ext4_mb_stats;
     extern long ext4_mb_max_to_scan;
    diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
    index 6e66175..c37418a 100644
    --- a/fs/ext4/inode.c
    +++ b/fs/ext4/inode.c
    @@ -2796,6 +2796,9 @@ static int ext4_writepages(struct address_space *mapping,
     		ext4_journal_stop(handle);
     	}
     
    +	if (wbc->nr_to_write < sbi->s_mb_small_req)
    +		wbc->nr_to_write = sbi->s_mb_small_req;
    +
     	if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
     		range_whole = 1;
     
    diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
    index 99ba720..3be3bef 100644
    --- a/fs/ext4/mballoc.c
    +++ b/fs/ext4/mballoc.c
    @@ -2339,6 +2339,101 @@ static void ext4_mb_seq_groups_stop(struct seq_file *seq, void *v)
     	.show   = ext4_mb_seq_groups_show,
     };
     
    +static int ext4_mb_check_and_update_prealloc(struct ext4_sb_info *sbi,
    +					     char *str, size_t cnt,
    +					     int update)
    +{
    +	unsigned long value;
    +	unsigned long prev = 0;
    +	char *cur;
    +	char *next;
    +	char *end;
    +	int num = 0;
    +
    +	cur = str;
    +	end = str + cnt;
    +	while (cur < end) {
    +		while ((cur < end) && (*cur == ' ')) cur++;
    +		/* Yuck - simple_strtol */
    +		value = simple_strtol(cur, &next, 0);
    +		if (value == 0)
    +			break;
    +		if (cur == next)
    +			return -EINVAL;
    +
    +		cur = next;
    +
    +		if (value > (sbi->s_blocks_per_group - 1 - 1 - sbi->s_itb_per_group))
    +			return -EINVAL;
    +
    +		/* they should add values in order */
    +		if (value <= prev)
    +			return -EINVAL;
    +
    +		if (update)
    +			sbi->s_mb_prealloc_table[num] = value;
    +
    +		prev = value;
    +		num++;
    +	}
    +
    +	if (num > EXT4_MAX_PREALLOC_TABLE - 1)
    +		return -EOVERFLOW;
    +
    +	if (update)
    +		sbi->s_mb_prealloc_table[num] = 0;
    +
    +	return 0;
    +}
    +
    +static ssize_t ext4_mb_prealloc_table_proc_write(struct file *file,
    +						 const char __user *buf,
    +						 size_t cnt, loff_t *pos)
    +{
    +	struct ext4_sb_info *sbi = EXT4_SB(PDE_DATA(file_inode(file)));
    +	char str[128];
    +	int rc;
    +
    +	if (cnt >= sizeof(str))
    +		return -EINVAL;
    +	if (copy_from_user(str, buf, cnt))
    +		return -EFAULT;
    +
    +	rc = ext4_mb_check_and_update_prealloc(sbi, str, cnt, 0);
    +	if (rc)
    +		return rc;
    +
    +	rc = ext4_mb_check_and_update_prealloc(sbi, str, cnt, 1);
    +	return rc ? rc : cnt;
    +}
    +
    +static int mb_prealloc_table_seq_show(struct seq_file *m, void *v)
    +{
    +	struct ext4_sb_info *sbi = EXT4_SB(m->private);
    +	int i;
    +
    +	for (i = 0; i < EXT4_MAX_PREALLOC_TABLE &&
    +			sbi->s_mb_prealloc_table[i] != 0; i++)
    +		seq_printf(m, "%ld ", sbi->s_mb_prealloc_table[i]);
    +	seq_printf(m, "\n");
    +
    +	return 0;
    +}
    +
    +static int mb_prealloc_table_seq_open(struct inode *inode, struct file *file)
    +{
    +	return single_open(file, mb_prealloc_table_seq_show, PDE_DATA(inode));
    +}
    +
    +const struct file_operations ext4_seq_prealloc_table_fops = {
    +	.owner	 = THIS_MODULE,
    +	.open	 = mb_prealloc_table_seq_open,
    +	.read	 = seq_read,
    +	.llseek	 = seq_lseek,
    +	.release = single_release,
    +	.write	 = ext4_mb_prealloc_table_proc_write,
    +};
    +
     static struct kmem_cache *get_groupinfo_cache(int blocksize_bits)
     {
     	int cache_index = blocksize_bits - EXT4_MIN_BLOCK_LOG_SIZE;
    @@ -2567,7 +2662,7 @@ static int ext4_groupinfo_create_slab(size_t size)
     int ext4_mb_init(struct super_block *sb)
     {
     	struct ext4_sb_info *sbi = EXT4_SB(sb);
    -	unsigned i, j;
    +	unsigned i, j, k, l;
     	unsigned offset, offset_incr;
     	unsigned max;
     	int ret;
    @@ -2616,7 +2711,6 @@ int ext4_mb_init(struct super_block *sb)
     	sbi->s_mb_max_to_scan = MB_DEFAULT_MAX_TO_SCAN;
     	sbi->s_mb_min_to_scan = MB_DEFAULT_MIN_TO_SCAN;
     	sbi->s_mb_stats = MB_DEFAULT_STATS;
    -	sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD;
     	sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS;
     	/*
     	 * The default group preallocation is 512, which for 4k block
    @@ -2640,9 +2734,28 @@ int ext4_mb_init(struct super_block *sb)
     	 * RAID stripe size so that preallocations don't fragment
     	 * the stripes.
     	 */
    -	if (sbi->s_stripe > 1) {
    -		sbi->s_mb_group_prealloc = roundup(
    -			sbi->s_mb_group_prealloc, sbi->s_stripe);
    +	/* Allocate table once */
    +	sbi->s_mb_prealloc_table = kzalloc(
    +		EXT4_MAX_PREALLOC_TABLE * sizeof(unsigned long), GFP_NOFS);
    +	if (!sbi->s_mb_prealloc_table) {
    +		ret = -ENOMEM;
    +		goto out;
    +	}
    +
    +	if (sbi->s_stripe == 0) {
    +		for (k = 0, l = 4; k <= 9; ++k, l *= 2)
    +			sbi->s_mb_prealloc_table[k] = l;
    +
    +		sbi->s_mb_small_req = 256;
    +		sbi->s_mb_large_req = 1024;
    +		sbi->s_mb_group_prealloc = 512;
    +	} else {
    +		for (k = 0, l = sbi->s_stripe; k <= 2; ++k, l *= 2)
    +			sbi->s_mb_prealloc_table[k] = l;
    +
    +		sbi->s_mb_small_req = sbi->s_stripe;
    +		sbi->s_mb_large_req = sbi->s_stripe * 8;
    +		sbi->s_mb_group_prealloc = sbi->s_stripe * 4;
     	}
     
     	sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group);
    @@ -2670,6 +2783,7 @@ int ext4_mb_init(struct super_block *sb)
     	free_percpu(sbi->s_locality_groups);
     	sbi->s_locality_groups = NULL;
     out:
    +	kfree(sbi->s_mb_prealloc_table);
     	kfree(sbi->s_mb_offsets);
     	sbi->s_mb_offsets = NULL;
     	kfree(sbi->s_mb_maxs);
    @@ -2932,7 +3046,6 @@ void ext4_exit_mballoc(void)
     	int err, len;
     
     	BUG_ON(ac->ac_status != AC_STATUS_FOUND);
    -	BUG_ON(ac->ac_b_ex.fe_len <= 0);
     
     	sb = ac->ac_sb;
     	sbi = EXT4_SB(sb);
    @@ -3062,13 +3175,14 @@ static void ext4_mb_normalize_group_request(struct ext4_allocation_context *ac)
     				struct ext4_allocation_request *ar)
     {
     	struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
    -	int bsbits, max;
    +	int bsbits, i, wind;
     	ext4_lblk_t end;
    -	loff_t size, start_off;
    +	loff_t size;
     	loff_t orig_size __maybe_unused;
     	ext4_lblk_t start;
     	struct ext4_inode_info *ei = EXT4_I(ac->ac_inode);
     	struct ext4_prealloc_space *pa;
    +	unsigned long value, last_non_zero;
     
     	/* do normalize only data requests, metadata requests
     	   do not need preallocation */
    @@ -3097,51 +3211,47 @@ static void ext4_mb_normalize_group_request(struct ext4_allocation_context *ac)
     	size = size << bsbits;
     	if (size < i_size_read(ac->ac_inode))
     		size = i_size_read(ac->ac_inode);
    -	orig_size = size;
    +	size = (size + ac->ac_sb->s_blocksize - 1) >> bsbits;
     
    -	/* max size of free chunks */
    -	max = 2 << bsbits;
    -
    -#define NRL_CHECK_SIZE(req, size, max, chunk_size)	\
    -		(req <= (size) || max <= (chunk_size))
    -
    -	/* first, try to predict filesize */
    -	/* XXX: should this table be tunable? */
    -	start_off = 0;
    -	if (size <= 16 * 1024) {
    -		size = 16 * 1024;
    -	} else if (size <= 32 * 1024) {
    -		size = 32 * 1024;
    -	} else if (size <= 64 * 1024) {
    -		size = 64 * 1024;
    -	} else if (size <= 128 * 1024) {
    -		size = 128 * 1024;
    -	} else if (size <= 256 * 1024) {
    -		size = 256 * 1024;
    -	} else if (size <= 512 * 1024) {
    -		size = 512 * 1024;
    -	} else if (size <= 1024 * 1024) {
    -		size = 1024 * 1024;
    -	} else if (NRL_CHECK_SIZE(size, 4 * 1024 * 1024, max, 2 * 1024)) {
    -		start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
    -						(21 - bsbits)) << 21;
    -		size = 2 * 1024 * 1024;
    -	} else if (NRL_CHECK_SIZE(size, 8 * 1024 * 1024, max, 4 * 1024)) {
    -		start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
    -							(22 - bsbits)) << 22;
    -		size = 4 * 1024 * 1024;
    -	} else if (NRL_CHECK_SIZE(ac->ac_o_ex.fe_len,
    -					(8<<20)>>bsbits, max, 8 * 1024)) {
    -		start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
    -							(23 - bsbits)) << 23;
    -		size = 8 * 1024 * 1024;
    +	start = wind = 0;
    +	value = last_non_zero = 0;
    +
    +	/* let's choose preallocation window depending on file size */
    +	for (i = 0; i < EXT4_MAX_PREALLOC_TABLE; i++) {
    +		value = sbi->s_mb_prealloc_table[i];
    +		if (value == 0)
    +			break;
    +		else
    +			last_non_zero = value;
    +
    +		if (size <= value) {
    +			wind = value;
    +			break;
    +		}
    +	}
    +
    +	if (wind == 0) {
    +		if (last_non_zero != 0) {
    +			u64 tstart, tend;
    +
    +			/* file is quite large, we now preallocate with
    +			 * the biggest configured window with regart to
    +			 * logical offset
    +			 */
    +			wind = last_non_zero;
    +			tstart = ac->ac_o_ex.fe_logical;
    +			do_div(tstart, wind);
    +			start = tstart * wind;
    +			tend = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len - 1;
    +			do_div(tend, wind);
    +			tend = tend * wind + wind;
    +			size = tend - start;
    +		}
     	} else {
    -		start_off = (loff_t) ac->ac_o_ex.fe_logical << bsbits;
    -		size	  = (loff_t) EXT4_C2B(EXT4_SB(ac->ac_sb),
    -					      ac->ac_o_ex.fe_len) << bsbits;
    +		size = wind;
     	}
    -	size = size >> bsbits;
    -	start = start_off >> bsbits;
    +
    +	orig_size = size;
     
     	/* don't cover already allocated blocks in selected range */
     	if (ar->pleft && start <= ar->lleft) {
    @@ -3223,7 +3333,6 @@ static void ext4_mb_normalize_group_request(struct ext4_allocation_context *ac)
     			 (unsigned long) ac->ac_o_ex.fe_logical);
     		BUG();
     	}
    -	BUG_ON(size <= 0 || size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb));
     
     	/* now prepare goal request */
     
    @@ -4191,11 +4300,19 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac)
     
     	/* don't use group allocation for large files */
     	size = max(size, isize);
    -	if (size > sbi->s_mb_stream_request) {
    +	if ((ac->ac_o_ex.fe_len >= sbi->s_mb_small_req) ||
    +	    (size >= sbi->s_mb_large_req)) {
     		ac->ac_flags |= EXT4_MB_STREAM_ALLOC;
     		return;
     	}
     
    +	/*
    +	 * request is so large that we don't care about
    +	 * streaming - it overweights any possible seek
    +	 */
    +	if (ac->ac_o_ex.fe_len >= sbi->s_mb_large_req)
    +		return;
    +
     	BUG_ON(ac->ac_lg != NULL);
     	/*
     	 * locality group prealloc space are per cpu. The reason for having
    diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
    index a616f58..a52b311 100644
    --- a/fs/ext4/namei.c
    +++ b/fs/ext4/namei.c
    @@ -752,8 +752,8 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
     	if (root->info.hash_version != DX_HASH_TEA &&
     	    root->info.hash_version != DX_HASH_HALF_MD4 &&
     	    root->info.hash_version != DX_HASH_LEGACY) {
    -		ext4_warning_inode(dir, "Unrecognised inode hash code %u",
    -				   root->info.hash_version);
    +		ext4_warning_inode(dir, "Unrecognised inode hash code %u for directory %lu",
    +				   root->info.hash_version, dir->i_ino);
     		goto fail;
     	}
     	if (fname)
    diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
    index 04b4f53..1375815 100644
    --- a/fs/ext4/sysfs.c
    +++ b/fs/ext4/sysfs.c
    @@ -184,7 +184,8 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
     EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
     EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
     EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs);
    -EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request);
    +EXT4_RW_ATTR_SBI_UI(mb_small_req, s_mb_small_req);
    +EXT4_RW_ATTR_SBI_UI(mb_large_req, s_mb_large_req);
     EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc);
     EXT4_RW_ATTR_SBI_UI(extent_max_zeroout_kb, s_extent_max_zeroout_kb);
     EXT4_ATTR(trigger_fs_error, 0200, trigger_test_error);
    @@ -213,7 +214,8 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
     	ATTR_LIST(mb_max_to_scan),
     	ATTR_LIST(mb_min_to_scan),
     	ATTR_LIST(mb_order2_req),
    -	ATTR_LIST(mb_stream_req),
    +	ATTR_LIST(mb_small_req),
    +	ATTR_LIST(mb_large_req),
     	ATTR_LIST(mb_group_prealloc),
     	ATTR_LIST(max_writeback_mb_bump),
     	ATTR_LIST(extent_max_zeroout_kb),
    @@ -413,6 +415,8 @@ int ext4_register_sysfs(struct super_block *sb)
     				sb);
     		proc_create_seq_data("mb_groups", S_IRUGO, sbi->s_proc,
     				&ext4_mb_seq_groups_ops, sb);
    +		proc_create_data("prealloc_table", S_IRUGO, sbi->s_proc,
    +				 &ext4_seq_prealloc_table_fops, sb);
     	}
     	return 0;
     }
    -- 
    1.8.3.1
#10 lore raw

PATCH 4/22 ext4: export inode management

In reply to James Simmons

Make ext4_delete_entry() exportable for osd-ldiskfs. Also add exportable ext4_create_inode().

---
 fs/ext4/ext4.h  |  6 ++++++
 fs/ext4/namei.c | 30 ++++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 4 deletions(-)
fs/ext4/ext4.h +6 -0
index 423ab4d..50f0c50 100644
@@ -2579,6 +2579,12 @@ extern int ext4_dirent_csum_verify(struct inode *inode,
 				   struct ext4_dir_entry *dirent);
 extern int ext4_orphan_add(handle_t *, struct inode *);
 extern int ext4_orphan_del(handle_t *, struct inode *);
+extern struct inode *ext4_create_inode(handle_t *handle,
+				       struct inode *dir, int mode,
+				       uid_t *owner);
+extern int ext4_delete_entry(handle_t *handle, struct inode * dir,
+			     struct ext4_dir_entry_2 *de_del,
+			     struct buffer_head *bh);
 extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
 				__u32 start_minor_hash, __u32 *next_hash);
 extern int ext4_search_dir(struct buffer_head *bh,
fs/ext4/namei.c +26 -4
index a52b311..a42a2db 100644
@@ -2459,10 +2459,9 @@ int ext4_generic_delete_entry(handle_t *handle,
 	return -ENOENT;
 }
 
-static int ext4_delete_entry(handle_t *handle,
-			     struct inode *dir,
-			     struct ext4_dir_entry_2 *de_del,
-			     struct buffer_head *bh)
+int ext4_delete_entry(handle_t *handle, struct inode *dir,
+		      struct ext4_dir_entry_2 *de_del,
+		      struct buffer_head *bh)
 {
 	int err, csum_size = 0;
 
@@ -2499,6 +2498,7 @@ static int ext4_delete_entry(handle_t *handle,
 		ext4_std_error(dir->i_sb, err);
 	return err;
 }
+EXPORT_SYMBOL(ext4_delete_entry);
 
 /*
  * Set directory link count to 1 if nlinks > EXT4_LINK_MAX, or if nlinks == 2
@@ -2545,6 +2545,28 @@ static int ext4_add_nondir(handle_t *handle,
 	return err;
 }
 
+/* Return locked inode, then the caller can modify the inode's states/flags
+ * before others finding it. The caller should unlock the inode by itself.
+ */
+struct inode *ext4_create_inode(handle_t *handle, struct inode *dir, int mode,
+				uid_t *owner)
+{
+	struct inode *inode;
+
+	inode = ext4_new_inode(handle, dir, mode, NULL, 0, owner, 0);
+	if (!IS_ERR(inode)) {
+		if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) {
+			inode->i_op = &ext4_special_inode_operations;
+		} else {
+			inode->i_op = &ext4_file_inode_operations;
+			inode->i_fop = &ext4_file_operations;
+			ext4_set_aops(inode);
+		}
+	}
+	return inode;
+}
+EXPORT_SYMBOL(ext4_create_inode);
+
 /*
  * By the time this is called, we already have created
  * the directory cache entry for the new file, but it
Signature · 1 line
1.8.3.1
#11 lore raw

PATCH 4/22 ext4: export inode management

Quoted 2 lines · James Simmons

Make ext4_delete_entry() exportable for osd-ldiskfs. Also add exportable ext4_create_inode().

Why can't lustre use vfs_unlink like everyone else? And vfs_mknod()? My hope is that what we land upstream will use generic interfaces only. If there is something that osd needs to do that the generic interfaces cannot support, then we need to look at how to add that to the generic interface.

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/3881f8b8/attachment.sig>

#12 lore raw

PATCH 4/22 ext4: export inode management

Quoted 14 lines · NeilBrown
Quoted 2 lines · James Simmons

Make ext4_delete_entry() exportable for osd-ldiskfs. Also add exportable ext4_create_inode().

Why can't lustre use vfs_unlink like everyone else? And vfs_mknod()? My hope is that what we land upstream will use generic interfaces only. If there is something that osd needs to do that the generic interfaces cannot support, then we need to look at how to add that to the generic interface.

That?s probably going to be a tough thing to do. At times we need certain things that are bad from vfs standpoint in general sense, but because we have various outside guarantees from locking and such - we can still do them.

nothing precise comes to mind now, but I remember various games with nlink count/moving and resurrecting such files.

We also have wider ?transaction boundaries?. Where say normal via-vfs transaction is metadata only, we can request certain data (from ext4 perspective, but metadata from Lustre) to be part of a particular transaction.

#13 lore raw

PATCH 5/22 ext4: various misc changes

In reply to James Simmons

Mostly exporting symbols for osd-ldiskfs.

---
 fs/ext4/balloc.c    |  1 +
 fs/ext4/ext4.h      | 26 +++++++++++++++++++++++++-
 fs/ext4/ext4_jbd2.c |  4 ++++
 fs/ext4/hash.c      |  1 +
 fs/ext4/ialloc.c    |  3 ++-
 fs/ext4/inode.c     |  6 ++++++
 fs/ext4/namei.c     | 13 +++++++------
 fs/ext4/super.c     |  9 +++------
 8 files changed, 49 insertions(+), 14 deletions(-)
fs/ext4/balloc.c +1 -0
index e5d6ee6..bca75c1 100644
@@ -294,6 +294,7 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
 		*bh = sbi->s_group_desc[group_desc];
 	return desc;
 }
+EXPORT_SYMBOL(ext4_get_group_desc);
 
 /*
  * Return the block number which was discovered to be invalid, or 0 if
fs/ext4/ext4.h +25 -1
index 50f0c50..eb2d124 100644
@@ -1617,6 +1617,8 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
 
 #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
 
+#define JOURNAL_START_HAS_3ARGS	1
+
 /*
  * Codes for operating systems
  */
@@ -1839,7 +1841,24 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
 
 EXTN_FEATURE_FUNCS(2)
 EXTN_FEATURE_FUNCS(3)
-EXTN_FEATURE_FUNCS(4)
+
+static inline bool ext4_has_unknown_ext4_compat_features(struct super_block *sb)
+{
+	return ((EXT4_SB(sb)->s_es->s_feature_compat &
+		cpu_to_le32(~EXT4_FEATURE_COMPAT_SUPP)) != 0);
+}
+
+static inline bool ext4_has_unknown_ext4_ro_compat_features(struct super_block *sb)
+{
+	return ((EXT4_SB(sb)->s_es->s_feature_ro_compat &
+		cpu_to_le32(~EXT4_FEATURE_RO_COMPAT_SUPP)) != 0);
+}
+
+static inline bool ext4_has_unknown_ext4_incompat_features(struct super_block *sb)
+{
+	return ((EXT4_SB(sb)->s_es->s_feature_incompat &
+		cpu_to_le32(~EXT4_FEATURE_INCOMPAT_SUPP)) != 0);
+}
 
 static inline bool ext4_has_compat_features(struct super_block *sb)
 {
@@ -3192,6 +3211,11 @@ extern int ext4_check_blockref(const char *, unsigned int,
 
 extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
 extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
+extern struct buffer_head *ext4_read_inode_bitmap(struct super_block *sb,
+						  ext4_group_t block_group);
+extern struct buffer_head *ext4_append(handle_t *handle,
+				       struct inode *inode,
+				       ext4_lblk_t *block);
 extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents);
 extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 			       struct ext4_map_blocks *map, int flags);
fs/ext4/ext4_jbd2.c +4 -0
index 7c70b08..fcec082 100644
@@ -81,6 +81,7 @@ handle_t *__ext4_journal_start_sb(struct super_block *sb, unsigned int line,
 	return jbd2__journal_start(journal, blocks, rsv_blocks, GFP_NOFS,
 				   type, line);
 }
+EXPORT_SYMBOL(__ext4_journal_start_sb);
 
 int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)
 {
@@ -108,6 +109,7 @@ int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)
 		__ext4_std_error(sb, where, line, err);
 	return err;
 }
+EXPORT_SYMBOL(__ext4_journal_stop);
 
 handle_t *__ext4_journal_start_reserved(handle_t *handle, unsigned int line,
 					int type)
@@ -173,6 +175,7 @@ int __ext4_journal_get_write_access(const char *where, unsigned int line,
 	}
 	return err;
 }
+EXPORT_SYMBOL(__ext4_journal_get_write_access);
 
 /*
  * The ext4 forget function must perform a revoke if we are freeing data
@@ -313,6 +316,7 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
 	}
 	return err;
 }
+EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
 
 int __ext4_handle_dirty_super(const char *where, unsigned int line,
 			      handle_t *handle, struct super_block *sb)
fs/ext4/hash.c +1 -0
index d358bfc..4648a8f 100644
@@ -300,3 +300,4 @@ int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
 #endif
 	return __ext4fs_dirhash(name, len, hinfo);
 }
+EXPORT_SYMBOL(ext4fs_dirhash);
fs/ext4/ialloc.c +2 -1
index 09ae4a4..68d41e6 100644
@@ -114,7 +114,7 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
  *
  * Return buffer_head of bitmap on success or NULL.
  */
-static struct buffer_head *
+struct buffer_head *
 ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
 {
 	struct ext4_group_desc *desc;
@@ -211,6 +211,7 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
 	put_bh(bh);
 	return ERR_PTR(err);
 }
+EXPORT_SYMBOL(ext4_read_inode_bitmap);
 
 /*
  * NOTE! When we get the inode, we're the only people
fs/ext4/inode.c +6 -0
index c37418a..5561351 100644
@@ -741,6 +741,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
 	}
 	return retval;
 }
+EXPORT_SYMBOL(ext4_map_blocks);
 
 /*
  * Update EXT4_MAP_FLAGS in bh->b_state. For buffer heads attached to pages
@@ -1027,6 +1028,7 @@ struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
 	put_bh(bh);
 	return ERR_PTR(-EIO);
 }
+EXPORT_SYMBOL(ext4_bread);
 
 /* Read a contiguous batch of blocks. */
 int ext4_bread_batch(struct inode *inode, ext4_lblk_t block, int bh_count,
@@ -4559,6 +4561,7 @@ int ext4_truncate(struct inode *inode)
 	trace_ext4_truncate_exit(inode);
 	return err;
 }
+EXPORT_SYMBOL(ext4_truncate);
 
 /*
  * ext4_get_inode_loc returns with an extra refcount against the inode's
@@ -4710,6 +4713,7 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
 	return __ext4_get_inode_loc(inode, iloc,
 		!ext4_test_inode_state(inode, EXT4_STATE_XATTR));
 }
+EXPORT_SYMBOL(ext4_get_inode_loc);
 
 static bool ext4_should_use_dax(struct inode *inode)
 {
@@ -5113,6 +5117,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
 	iget_failed(inode);
 	return ERR_PTR(ret);
 }
+EXPORT_SYMBOL(__ext4_iget);
 
 static int ext4_inode_blocks_set(handle_t *handle,
 				struct ext4_inode *raw_inode,
@@ -6050,6 +6055,7 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
 
 	return ext4_mark_iloc_dirty(handle, inode, &iloc);
 }
+EXPORT_SYMBOL(ext4_mark_inode_dirty);
 
 /*
  * ext4_dirty_inode() is called from __mark_inode_dirty()
fs/ext4/namei.c +7 -6
index a42a2db..91fc7fe 100644
@@ -50,9 +50,9 @@
 #define NAMEI_RA_BLOCKS  4
 #define NAMEI_RA_SIZE	     (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)
 
-static struct buffer_head *ext4_append(handle_t *handle,
-					struct inode *inode,
-					ext4_lblk_t *block)
+struct buffer_head *ext4_append(handle_t *handle,
+				struct inode *inode,
+				ext4_lblk_t *block)
 {
 	struct buffer_head *bh;
 	int err;
@@ -2511,24 +2511,25 @@ int ext4_delete_entry(handle_t *handle, struct inode *dir,
  * for checking S_ISDIR(inode) (since the INODE_INDEX feature will not be set
  * on regular files) and to avoid creating huge/slow non-HTREE directories.
  */
-static void ext4_inc_count(handle_t *handle, struct inode *inode)
+void ext4_inc_count(handle_t *handle, struct inode *inode)
 {
 	inc_nlink(inode);
 	if (is_dx(inode) &&
 	    (inode->i_nlink > EXT4_LINK_MAX || inode->i_nlink == 2))
 		set_nlink(inode, 1);
 }
+EXPORT_SYMBOL(ext4_inc_count);
 
 /*
  * If a directory had nlink == 1, then we should let it be 1. This indicates
  * directory has >EXT4_LINK_MAX subdirs.
  */
-static void ext4_dec_count(handle_t *handle, struct inode *inode)
+void ext4_dec_count(handle_t *handle, struct inode *inode)
 {
 	if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2)
 		drop_nlink(inode);
 }
-
+EXPORT_SYMBOL(ext4_dec_count);
 
 static int ext4_add_nondir(handle_t *handle,
 		struct dentry *dentry, struct inode *inode)
fs/ext4/super.c +3 -6
index 4079605..d15c26c 100644
@@ -279,6 +279,7 @@ __u32 ext4_itable_unused_count(struct super_block *sb,
 		(EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
 		 (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0);
 }
+EXPORT_SYMBOL(ext4_itable_unused_count);
 
 void ext4_block_bitmap_set(struct super_block *sb,
 			   struct ext4_group_desc *bg, ext4_fsblk_t blk)
@@ -658,6 +659,7 @@ void __ext4_std_error(struct super_block *sb, const char *function,
 	save_error_info(sb, function, line);
 	ext4_handle_error(sb);
 }
+EXPORT_SYMBOL(__ext4_std_error);
 
 /*
  * ext4_abort is a much stronger failure handler than ext4_error.  The
@@ -5101,6 +5103,7 @@ int ext4_force_commit(struct super_block *sb)
 	journal = EXT4_SB(sb)->s_journal;
 	return ext4_journal_force_commit(journal);
 }
+EXPORT_SYMBOL(ext4_force_commit);
 
 static int ext4_sync_fs(struct super_block *sb, int wait)
 {
@@ -6115,16 +6118,12 @@ static int __init ext4_init_fs(void)
 	err = init_inodecache();
 	if (err)
 		goto out1;
-	register_as_ext3();
-	register_as_ext2();
 	err = register_filesystem(&ext4_fs_type);
 	if (err)
 		goto out;
 
 	return 0;
 out:
-	unregister_as_ext2();
-	unregister_as_ext3();
 	destroy_inodecache();
 out1:
 	ext4_exit_mballoc();
@@ -6145,8 +6144,6 @@ static int __init ext4_init_fs(void)
 static void __exit ext4_exit_fs(void)
 {
 	ext4_destroy_lazyinit_thread();
-	unregister_as_ext2();
-	unregister_as_ext3();
 	unregister_filesystem(&ext4_fs_type);
 	destroy_inodecache();
 	ext4_exit_mballoc();
Signature · 1 line
1.8.3.1
#14 lore raw

PATCH 6/22 ext4: add extra checks for mballoc

In reply to James Simmons

Handle mballoc corruptions.

---
 fs/ext4/ext4.h    |   1 +
 fs/ext4/mballoc.c | 110 +++++++++++++++++++++++++++++++++++++++++++++---------
 fs/ext4/mballoc.h |   2 +-
 3 files changed, 94 insertions(+), 19 deletions(-)
fs/ext4/ext4.h +1 -0
index eb2d124..e321286 100644
@@ -2957,6 +2957,7 @@ struct ext4_group_info {
 	ext4_grpblk_t	bb_fragments;	/* nr of freespace fragments */
 	ext4_grpblk_t	bb_largest_free_order;/* order of largest frag in BG */
 	struct          list_head bb_prealloc_list;
+	unsigned long	bb_prealloc_nr;
 #ifdef DOUBLE_CHECK
 	void            *bb_bitmap;
 #endif
fs/ext4/mballoc.c +92 -18

254 lines not on this page · raw message

fs/ext4/mballoc.h +1 -1
index 88c98f1..8325ad9 100644
@@ -70,7 +70,7 @@
 /*
  * for which requests use 2^N search using buddies
  */
-#define MB_DEFAULT_ORDER2_REQS		2
+#define MB_DEFAULT_ORDER2_REQS		8
 
 /*
  * default group prealloc size 512 blocks
Signature · 1 line
1.8.3.1
#15 lore raw

PATCH 6/22 ext4: add extra checks for mballoc

Quoted 1 line · James Simmons

Handle mballoc corruptions.

"Handle" here mean "return -EIO if corruptions are found" ??

Sounds like a good thing to do. I cannot comment on the code without understand the fs more, but...

fs/ext4/mballoc.h line 73

Quoted 10 lines
fs/ext4/mballoc.h +1 -1
index 88c98f1..8325ad9 100644
@@ -70,7 +70,7 @@
 /*
  * for which requests use 2^N search using buddies
  */
-#define MB_DEFAULT_ORDER2_REQS		2
+#define MB_DEFAULT_ORDER2_REQS		8

I don't think this belongs with the reset of the patch.

NeilBrown

Quoted 5 lines
fs/ext4/mballoc.h +0 -0
 /*
  * default group prealloc size 512 blocks
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/59f2a4c0/attachment.sig>

#16 lore raw

PATCH 7/22 ext4: update .. for hash indexed directory

In reply to James Simmons

Handle special .. case.

---
 fs/ext4/namei.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
fs/ext4/namei.c +70 -0
index 91fc7fe..dd64a10 100644
@@ -2133,6 +2133,73 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 	return retval;
 }
 
+/* update ".." for hash-indexed directory, split the item "." if necessary */
+static int ext4_update_dotdot(handle_t *handle, struct dentry *dentry,
+			      struct inode *inode)
+{
+	struct inode *dir = dentry->d_parent->d_inode;
+	struct buffer_head *dir_block;
+	struct ext4_dir_entry_2 *de;
+	int len, journal = 0, err = 0;
+
+	if (IS_ERR(handle))
+		return PTR_ERR(handle);
+
+	if (IS_DIRSYNC(dir))
+		handle->h_sync = 1;
+
+	dir_block = ext4_bread(handle, dir, 0, 0);
+	if (IS_ERR(dir_block)) {
+		err = PTR_ERR(dir_block);
+		goto out;
+	}
+
+	de = (struct ext4_dir_entry_2 *)dir_block->b_data;
+	/* the first item must be "." */
+	assert(de->name_len == 1 && de->name[0] == '.');
+	len = le16_to_cpu(de->rec_len);
+	assert(len >= EXT4_DIR_REC_LEN(1));
+	if (len > EXT4_DIR_REC_LEN(1)) {
+		BUFFER_TRACE(dir_block, "get_write_access");
+		err = ext4_journal_get_write_access(handle, dir_block);
+		if (err)
+			goto out_journal;
+
+		journal = 1;
+		de->rec_len = cpu_to_le16(EXT4_DIR_REC_LEN(1));
+	}
+
+	len -= EXT4_DIR_REC_LEN(1);
+	assert(len == 0 || len >= EXT4_DIR_REC_LEN(2));
+	de = (struct ext4_dir_entry_2 *)
+		((char *) de + le16_to_cpu(de->rec_len));
+	if (!journal) {
+		BUFFER_TRACE(dir_block, "get_write_access");
+		err = ext4_journal_get_write_access(handle, dir_block);
+		if (err)
+			goto out_journal;
+	}
+
+	de->inode = cpu_to_le32(inode->i_ino);
+	if (len > 0)
+		de->rec_len = cpu_to_le16(len);
+	else
+		assert(le16_to_cpu(de->rec_len) >= EXT4_DIR_REC_LEN(2));
+	de->name_len = 2;
+	strcpy(de->name, "..");
+	ext4_set_de_type(dir->i_sb, de, S_IFDIR);
+
+out_journal:
+	if (journal) {
+		BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata");
+		err = ext4_handle_dirty_dirent_node(handle, dir, dir_block);
+		ext4_mark_inode_dirty(handle, dir);
+	}
+	brelse(dir_block);
+out:
+	return err;
+}
+
 /*
  *	ext4_add_entry()
  *
@@ -2189,6 +2256,9 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
 	}
 
 	if (is_dx(dir)) {
+		if (dentry->d_name.len == 2 &&
+		    memcmp(dentry->d_name.name, "..", 2) == 0)
+			return ext4_update_dotdot(handle, dentry, inode);
 		retval = ext4_dx_add_entry(handle, &fname, dir, inode);
 		if (!retval || (retval != ERR_BAD_DX_DIR))
 			goto out;
Signature · 1 line
1.8.3.1
#17 lore raw

PATCH 7/22 ext4: update .. for hash indexed directory

Quoted 1 line · James Simmons

Handle special .. case.

This seems to be for adding ".." to a directory. That happens at "mkdir". When else would you want to do that? Is this an on-line fsck-repair thing?

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/3d20ff15/attachment.sig>

#18 lore raw

PATCH 8/22 ext4: kill off struct dx_root

In reply to James Simmons

Use struct dx_root_info directly.

---
 fs/ext4/namei.c | 110 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 58 insertions(+), 52 deletions(-)
fs/ext4/namei.c +58 -52
index dd64a10..4c45570 100644
@@ -197,23 +197,13 @@ struct dx_entry
  * dirent the two low bits of the hash version will be zero.  Therefore, the
  * hash version mod 4 should never be 0.  Sincerely, the paranoia department.
  */
-
-struct dx_root
+struct dx_root_info
 {
-	struct fake_dirent dot;
-	char dot_name[4];
-	struct fake_dirent dotdot;
-	char dotdot_name[4];
-	struct dx_root_info
-	{
-		__le32 reserved_zero;
-		u8 hash_version;
-		u8 info_length; /* 8 */
-		u8 indirect_levels;
-		u8 unused_flags;
-	}
-	info;
-	struct dx_entry	entries[0];
+	__le32 reserved_zero;
+	u8 hash_version;
+	u8 info_length; /* 8 */
+	u8 indirect_levels;
+	u8 unused_flags;
 };
 
 struct dx_node
@@ -514,6 +504,16 @@ static inline int ext4_handle_dirty_dx_node(handle_t *handle,
  * Future: use high four bits of block for coalesce-on-delete flags
  * Mask them off for now.
  */
+struct dx_root_info *dx_get_dx_info(struct ext4_dir_entry_2 *de)
+{
+	/* get dotdot first */
+	de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(1));
+
+	/* dx root info is after dotdot entry */
+	de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(2));
+
+	return (struct dx_root_info *)de;
+}
 
 static inline ext4_lblk_t dx_get_block(struct dx_entry *entry)
 {
@@ -738,7 +738,7 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
 {
 	unsigned count, indirect;
 	struct dx_entry *at, *entries, *p, *q, *m;
-	struct dx_root *root;
+	struct dx_root_info *info;
 	struct dx_frame *frame = frame_in;
 	struct dx_frame *ret_err = ERR_PTR(ERR_BAD_DX_DIR);
 	u32 hash;
@@ -748,17 +748,17 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
 	if (IS_ERR(frame->bh))
 		return (struct dx_frame *) frame->bh;
 
-	root = (struct dx_root *) frame->bh->b_data;
-	if (root->info.hash_version != DX_HASH_TEA &&
-	    root->info.hash_version != DX_HASH_HALF_MD4 &&
-	    root->info.hash_version != DX_HASH_LEGACY) {
+	info = dx_get_dx_info((struct ext4_dir_entry_2 *)frame->bh->b_data);
+	if (info->hash_version != DX_HASH_TEA &&
+	    info->hash_version != DX_HASH_HALF_MD4 &&
+	    info->hash_version != DX_HASH_LEGACY) {
 		ext4_warning_inode(dir, "Unrecognised inode hash code %u for directory %lu",
-				   root->info.hash_version, dir->i_ino);
+				   info->hash_version, dir->i_ino);
 		goto fail;
 	}
 	if (fname)
 		hinfo = &fname->hinfo;
-	hinfo->hash_version = root->info.hash_version;
+	hinfo->hash_version = info->hash_version;
 	if (hinfo->hash_version <= DX_HASH_TEA)
 		hinfo->hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
 	hinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed;
@@ -766,13 +766,13 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
 		ext4fs_dirhash(dir, fname_name(fname), fname_len(fname), hinfo);
 	hash = hinfo->hash;
 
-	if (root->info.unused_flags & 1) {
+	if (info->unused_flags & 1) {
 		ext4_warning_inode(dir, "Unimplemented hash flags: %#06x",
-				   root->info.unused_flags);
+				   info->unused_flags);
 		goto fail;
 	}
 
-	indirect = root->info.indirect_levels;
+	indirect = info->indirect_levels;
 	if (indirect >= ext4_dir_htree_level(dir->i_sb)) {
 		ext4_warning(dir->i_sb,
 			     "Directory (ino: %lu) htree depth %#06x exceed"
@@ -785,14 +785,13 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
 		goto fail;
 	}
 
-	entries = (struct dx_entry *)(((char *)&root->info) +
-				      root->info.info_length);
+	entries = (struct dx_entry *)(((char *)info) + info->info_length);
 
 	if (dx_get_limit(entries) != dx_root_limit(dir,
-						   root->info.info_length)) {
+						   info->info_length)) {
 		ext4_warning_inode(dir, "dx entry: limit %u != root limit %u",
 				   dx_get_limit(entries),
-				   dx_root_limit(dir, root->info.info_length));
+				   dx_root_limit(dir, info->info_length));
 		goto fail;
 	}
 
@@ -877,7 +876,7 @@ static void dx_release(struct dx_frame *frames)
 	if (frames[0].bh == NULL)
 		return;
 
-	info = &((struct dx_root *)frames[0].bh->b_data)->info;
+	info = dx_get_dx_info((struct ext4_dir_entry_2 *)frames[0].bh->b_data);
 	/* save local copy, "info" may be freed after brelse() */
 	indirect_levels = info->indirect_levels;
 	for (i = 0; i <= indirect_levels; i++) {
@@ -2020,17 +2019,16 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 			    struct inode *inode, struct buffer_head *bh)
 {
 	struct buffer_head *bh2;
-	struct dx_root	*root;
 	struct dx_frame	frames[EXT4_HTREE_LEVEL], *frame;
 	struct dx_entry *entries;
-	struct ext4_dir_entry_2	*de, *de2;
+	struct ext4_dir_entry_2	*de, *de2, *dot_de, *dotdot_de;
 	struct ext4_dir_entry_tail *t;
 	char		*data1, *top;
 	unsigned	len;
 	int		retval;
 	unsigned	blocksize;
 	ext4_lblk_t  block;
-	struct fake_dirent *fde;
+	struct dx_root_info *dx_info;
 	int csum_size = 0;
 
 	if (ext4_has_metadata_csum(inode->i_sb))
@@ -2045,18 +2043,19 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 		brelse(bh);
 		return retval;
 	}
-	root = (struct dx_root *) bh->b_data;
+
+	dot_de = (struct ext4_dir_entry_2 *)bh->b_data;
+	dotdot_de = ext4_next_entry(dot_de, blocksize);
 
 	/* The 0th block becomes the root, move the dirents out */
-	fde = &root->dotdot;
-	de = (struct ext4_dir_entry_2 *)((char *)fde +
-		ext4_rec_len_from_disk(fde->rec_len, blocksize));
-	if ((char *) de >= (((char *) root) + blocksize)) {
+	de = (struct ext4_dir_entry_2 *)((char *)dotdot_de +
+		ext4_rec_len_from_disk(dotdot_de->rec_len, blocksize));
+	if ((char *)de >= (((char *)dot_de) + blocksize)) {
 		EXT4_ERROR_INODE(dir, "invalid rec_len for '..'");
 		brelse(bh);
 		return -EFSCORRUPTED;
 	}
-	len = ((char *) root) + (blocksize - csum_size) - (char *) de;
+	len = ((char *)dot_de) + (blocksize - csum_size) - (char *) de;
 
 	/* Allocate new block for the 0th block's dirents */
 	bh2 = ext4_append(handle, dir, &block);
@@ -2082,19 +2081,24 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 	}
 
 	/* Initialize the root; the dot dirents already exist */
-	de = (struct ext4_dir_entry_2 *) (&root->dotdot);
-	de->rec_len = ext4_rec_len_to_disk(blocksize - EXT4_DIR_REC_LEN(2),
-					   blocksize);
-	memset (&root->info, 0, sizeof(root->info));
-	root->info.info_length = sizeof(root->info);
-	root->info.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
-	entries = root->entries;
+	dotdot_de->rec_len =
+		ext4_rec_len_to_disk(blocksize - le16_to_cpu(dot_de->rec_len),
+				     blocksize);
+
+	/* initialize hashing info */
+	dx_info = dx_get_dx_info(dot_de);
+	memset(dx_info, 0, sizeof(*dx_info));
+	dx_info->info_length = sizeof(*dx_info);
+	dx_info->hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
+
+	entries = (void *)dx_info + sizeof(*dx_info);
+
 	dx_set_block(entries, 1);
 	dx_set_count(entries, 1);
-	dx_set_limit(entries, dx_root_limit(dir, sizeof(root->info)));
+	dx_set_limit(entries, dx_root_limit(dir, sizeof(*dx_info)));
 
 	/* Initialize as for dx_probe */
-	fname->hinfo.hash_version = root->info.hash_version;
+	fname->hinfo.hash_version = dx_info->hash_version;
 	if (fname->hinfo.hash_version <= DX_HASH_TEA)
 		fname->hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
 	fname->hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
@@ -2443,7 +2447,8 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
 				goto journal_error;
 			}
 		} else {
-			struct dx_root *dxroot;
+			struct dx_root_info *info;
+
 			memcpy((char *) entries2, (char *) entries,
 			       icount * sizeof(struct dx_entry));
 			dx_set_limit(entries2, dx_node_limit(dir));
@@ -2451,8 +2456,9 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
 			/* Set up root */
 			dx_set_count(entries, 1);
 			dx_set_block(entries + 0, newblock);
-			dxroot = (struct dx_root *)frames[0].bh->b_data;
-			dxroot->info.indirect_levels += 1;
+			info = dx_get_dx_info((struct ext4_dir_entry_2 *)
+					      frames[0].bh->b_data);
+			info->indirect_levels += 1;
 			dxtrace(printk(KERN_DEBUG
 				       "Creating %d level index...\n",
 				       dxroot->info.indirect_levels));
Signature · 1 line
1.8.3.1
#19 lore raw

PATCH 8/22 ext4: kill off struct dx_root

Quoted 1 line · James Simmons

Use struct dx_root_info directly.

This looks like a style change.
Instead of a 'struct' that models the start of an on-disk directory block, the location of some fields is done using calculations instead.

Why would we want to do that? Might we want dx_root_info to be at a different offset in the directory ??

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/63f18b48/attachment.sig>

#20 lore raw

PATCH 8/22 ext4: kill off struct dx_root

This is needed so that we can add extra data to struct ext4_dir_entry (Lustre FID) via the "dirdata" feature, and struct dx_root assumes "." and ".." entries are a fixed size.

So there is a reason for the patch, and I think it would be acceptable upstream. Artem @ Cray has an updated version of this patch that was submitted upstream to linux-ext4 and reviewed, but it needs to be refreshed again.

Cheers, Andreas

Quoted 14 lines · NeilBrown
Quoted 4 lines · James Simmons

Use struct dx_root_info directly.

This looks like a style change.
Instead of a 'struct' that models the start of an on-disk directory block, the location of some fields is done using calculations instead.

Why would we want to do that? Might we want dx_root_info to be at a different offset in the directory ??

NeilBrown

#21 lore raw

PATCH 8/22 ext4: kill off struct dx_root

In reply to NeilBrown

We need this for dirdata feature.

?On 22/07/2019, 07:52, "NeilBrown" <[email protected]> wrote:

On Sun, Jul 21 2019, James Simmons wrote:

> Use struct dx_root_info directly.

This looks like a style change.
Instead of a 'struct' that models the start of an on-disk directory block, the location of some fields is done using calculations instead.

Why would we want to do that? Might we want dx_root_info to be at a different offset in the directory ??

NeilBrown

#22 lore raw

PATCH 9/22 ext4: fix mballoc pa free mismatch

In reply to James Simmons

Intoduce pa_error so we can find any mballoc pa cleanup problems.

---
 fs/ext4/mballoc.c | 45 +++++++++++++++++++++++++++++++++++++++------
 fs/ext4/mballoc.h |  2 ++
 2 files changed, 41 insertions(+), 6 deletions(-)
fs/ext4/mballoc.c +39 -6
index 483fc0f..463fba6 100644
@@ -3863,6 +3863,7 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac,
 	INIT_LIST_HEAD(&pa->pa_group_list);
 	pa->pa_deleted = 0;
 	pa->pa_type = MB_INODE_PA;
+	pa->pa_error = 0;
 
 	mb_debug(1, "new inode pa %p: %llu/%u for %u\n", pa,
 			pa->pa_pstart, pa->pa_len, pa->pa_lstart);
@@ -3924,6 +3925,7 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac,
 	INIT_LIST_HEAD(&pa->pa_group_list);
 	pa->pa_deleted = 0;
 	pa->pa_type = MB_GROUP_PA;
+	pa->pa_error = 0;
 
 	mb_debug(1, "new group pa %p: %llu/%u for %u\n", pa,
 			pa->pa_pstart, pa->pa_len, pa->pa_lstart);
@@ -3983,7 +3985,9 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac)
 	unsigned long long grp_blk_start;
 	int free = 0;
 
+	assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group));
 	BUG_ON(pa->pa_deleted == 0);
+	BUG_ON(pa->pa_inode == NULL);
 	ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
 	grp_blk_start = pa->pa_pstart - EXT4_C2B(sbi, bit);
 	BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
@@ -4006,12 +4010,19 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac)
 		mb_free_blocks(pa->pa_inode, e4b, bit, next - bit);
 		bit = next + 1;
 	}
-	if (free != pa->pa_free) {
-		ext4_msg(e4b->bd_sb, KERN_CRIT,
-			 "pa %p: logic %lu, phys. %lu, len %lu",
-			 pa, (unsigned long) pa->pa_lstart,
-			 (unsigned long) pa->pa_pstart,
-			 (unsigned long) pa->pa_len);
+
+	/* "free < pa->pa_free" means we maybe double alloc the same blocks,
+	 * otherwise maybe leave some free blocks unavailable, no need to BUG.
+	 */
+	if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
+		ext4_error(sb, "pa free mismatch: [pa %p] "
+				"[phy %lu] [logic %lu] [len %u] [free %u] "
+				"[error %u] [inode %lu] [freed %u]", pa,
+				(unsigned long)pa->pa_pstart,
+				(unsigned long)pa->pa_lstart,
+				(unsigned)pa->pa_len, (unsigned)pa->pa_free,
+				(unsigned)pa->pa_error, pa->pa_inode->i_ino,
+				free);
 		ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u",
 					free, pa->pa_free);
 		/*
@@ -4019,6 +4030,8 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac)
 		 * from the bitmap and continue.
 		 */
 	}
+	/* do not verify if the file system is being umounted */
+	BUG_ON(atomic_read(&sb->s_active) > 0 && pa->pa_free != free);
 	atomic_add(free, &sbi->s_mb_discarded);
 
 	return 0;
@@ -4764,6 +4777,26 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
 		ac->ac_b_ex.fe_len = 0;
 		ar->len = 0;
 		ext4_mb_show_ac(ac);
+		if (ac->ac_pa) {
+			struct ext4_prealloc_space *pa = ac->ac_pa;
+
+			/* We can not make sure whether the bitmap has
+			 * been updated or not when fail case. So can
+			 * not revert pa_free back, just mark pa_error
+			 */
+			pa->pa_error++;
+			ext4_error(sb,
+				   "Updating bitmap error: [err %d] "
+				   "[pa %p] [phy %lu] [logic %lu] "
+				   "[len %u] [free %u] [error %u] "
+				   "[inode %lu]", *errp, pa,
+				   (unsigned long)pa->pa_pstart,
+				   (unsigned long)pa->pa_lstart,
+				   (unsigned)pa->pa_len,
+				   (unsigned)pa->pa_free,
+				   (unsigned)pa->pa_error,
+				   pa->pa_inode ? pa->pa_inode->i_ino : 0);
+		}
 	}
 	ext4_mb_release_context(ac);
 out:
fs/ext4/mballoc.h +2 -0
index 8325ad9..e00c3b7 100644
@@ -20,6 +20,7 @@
 #include <linux/seq_file.h>
 #include <linux/blkdev.h>
 #include <linux/mutex.h>
+#include <linux/genhd.h>
 #include "ext4_jbd2.h"
 #include "ext4.h"
 
@@ -111,6 +112,7 @@ struct ext4_prealloc_space {
 	ext4_grpblk_t		pa_len;		/* len of preallocated chunk */
 	ext4_grpblk_t		pa_free;	/* how many blocks are free */
 	unsigned short		pa_type;	/* pa type. inode or group */
+	unsigned short		pa_error;
 	spinlock_t		*pa_obj_lock;
 	struct inode		*pa_inode;	/* hack, for history only */
 };
Signature · 1 line
1.8.3.1
#23 lore raw

PATCH 9/22 ext4: fix mballoc pa free mismatch

Quoted 1 line · James Simmons

Intoduce pa_error so we can find any mballoc pa cleanup problems.

This patch seems to make sense, though

fs/ext4/mballoc.c static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac) · line 4034

Quoted 1 line
fs/ext4/mballoc.c +1 -0
+	BUG_ON(atomic_read(&sb->s_active) > 0 && pa->pa_free != free);

should probably be a WARN_ON and

Quoted 1 line

+#include <linux/genhd.h>

seems un-called for.

NeilBrown

Quoted 121 lines
---
 fs/ext4/mballoc.c | 45 +++++++++++++++++++++++++++++++++++++++------
 fs/ext4/mballoc.h |  2 ++
 2 files changed, 41 insertions(+), 6 deletions(-)
fs/ext4/mballoc.c +39 -6
index 483fc0f..463fba6 100644
@@ -3863,6 +3863,7 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac,
 	INIT_LIST_HEAD(&pa->pa_group_list);
 	pa->pa_deleted = 0;
 	pa->pa_type = MB_INODE_PA;
+	pa->pa_error = 0;
 
 	mb_debug(1, "new inode pa %p: %llu/%u for %u\n", pa,
 			pa->pa_pstart, pa->pa_len, pa->pa_lstart);
@@ -3924,6 +3925,7 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac,
 	INIT_LIST_HEAD(&pa->pa_group_list);
 	pa->pa_deleted = 0;
 	pa->pa_type = MB_GROUP_PA;
+	pa->pa_error = 0;
 
 	mb_debug(1, "new group pa %p: %llu/%u for %u\n", pa,
 			pa->pa_pstart, pa->pa_len, pa->pa_lstart);
@@ -3983,7 +3985,9 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac)
 	unsigned long long grp_blk_start;
 	int free = 0;
 
+	assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group));
 	BUG_ON(pa->pa_deleted == 0);
+	BUG_ON(pa->pa_inode == NULL);
 	ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
 	grp_blk_start = pa->pa_pstart - EXT4_C2B(sbi, bit);
 	BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
@@ -4006,12 +4010,19 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac)
 		mb_free_blocks(pa->pa_inode, e4b, bit, next - bit);
 		bit = next + 1;
 	}
-	if (free != pa->pa_free) {
-		ext4_msg(e4b->bd_sb, KERN_CRIT,
-			 "pa %p: logic %lu, phys. %lu, len %lu",
-			 pa, (unsigned long) pa->pa_lstart,
-			 (unsigned long) pa->pa_pstart,
-			 (unsigned long) pa->pa_len);
+
+	/* "free < pa->pa_free" means we maybe double alloc the same blocks,
+	 * otherwise maybe leave some free blocks unavailable, no need to BUG.
+	 */
+	if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
+		ext4_error(sb, "pa free mismatch: [pa %p] "
+				"[phy %lu] [logic %lu] [len %u] [free %u] "
+				"[error %u] [inode %lu] [freed %u]", pa,
+				(unsigned long)pa->pa_pstart,
+				(unsigned long)pa->pa_lstart,
+				(unsigned)pa->pa_len, (unsigned)pa->pa_free,
+				(unsigned)pa->pa_error, pa->pa_inode->i_ino,
+				free);
 		ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u",
 					free, pa->pa_free);
 		/*
@@ -4019,6 +4030,8 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac)
 		 * from the bitmap and continue.
 		 */
 	}
+	/* do not verify if the file system is being umounted */
+	BUG_ON(atomic_read(&sb->s_active) > 0 && pa->pa_free != free);
 	atomic_add(free, &sbi->s_mb_discarded);
 
 	return 0;
@@ -4764,6 +4777,26 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
 		ac->ac_b_ex.fe_len = 0;
 		ar->len = 0;
 		ext4_mb_show_ac(ac);
+		if (ac->ac_pa) {
+			struct ext4_prealloc_space *pa = ac->ac_pa;
+
+			/* We can not make sure whether the bitmap has
+			 * been updated or not when fail case. So can
+			 * not revert pa_free back, just mark pa_error
+			 */
+			pa->pa_error++;
+			ext4_error(sb,
+				   "Updating bitmap error: [err %d] "
+				   "[pa %p] [phy %lu] [logic %lu] "
+				   "[len %u] [free %u] [error %u] "
+				   "[inode %lu]", *errp, pa,
+				   (unsigned long)pa->pa_pstart,
+				   (unsigned long)pa->pa_lstart,
+				   (unsigned)pa->pa_len,
+				   (unsigned)pa->pa_free,
+				   (unsigned)pa->pa_error,
+				   pa->pa_inode ? pa->pa_inode->i_ino : 0);
+		}
 	}
 	ext4_mb_release_context(ac);
 out:
fs/ext4/mballoc.h +2 -0
index 8325ad9..e00c3b7 100644
@@ -20,6 +20,7 @@
 #include <linux/seq_file.h>
 #include <linux/blkdev.h>
 #include <linux/mutex.h>
+#include <linux/genhd.h>
 #include "ext4_jbd2.h"
 #include "ext4.h"
 
@@ -111,6 +112,7 @@ struct ext4_prealloc_space {
 	ext4_grpblk_t		pa_len;		/* len of preallocated chunk */
 	ext4_grpblk_t		pa_free;	/* how many blocks are free */
 	unsigned short		pa_type;	/* pa type. inode or group */
+	unsigned short		pa_error;
 	spinlock_t		*pa_obj_lock;
 	struct inode		*pa_inode;	/* hack, for history only */
 };
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/0e7781e6/attachment.sig>

#24 lore raw

PATCH 10/22 ext4: add data in dentry feature

In reply to James Simmons

Lustre likes to stuff extra data into dentrys.

---
 fs/ext4/dir.c    |  14 ++--
 fs/ext4/ext4.h   |  92 +++++++++++++++++++++--
 fs/ext4/inline.c |  16 ++--
 fs/ext4/namei.c  | 217 +++++++++++++++++++++++++++++++++++++++++++------------
 fs/ext4/super.c  |   4 +-
 5 files changed, 278 insertions(+), 65 deletions(-)
fs/ext4/dir.c +9 -5
index c7843b1..20e0d32 100644
@@ -70,11 +70,11 @@ int __ext4_check_dir_entry(const char *function, unsigned int line,
 	const int rlen = ext4_rec_len_from_disk(de->rec_len,
 						dir->i_sb->s_blocksize);
 
-	if (unlikely(rlen < EXT4_DIR_REC_LEN(1)))
+	if (unlikely(rlen < __EXT4_DIR_REC_LEN(1)))
 		error_msg = "rec_len is smaller than minimal";
 	else if (unlikely(rlen % 4 != 0))
 		error_msg = "rec_len % 4 != 0";
-	else if (unlikely(rlen < EXT4_DIR_REC_LEN(de->name_len)))
+	else if (unlikely(rlen < __EXT4_DIR_REC_LEN(de->name_len)))
 		error_msg = "rec_len is too small for name_len";
 	else if (unlikely(((char *) de - buf) + rlen > size))
 		error_msg = "directory entry overrun";
@@ -219,7 +219,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
 				 * failure will be detected in the
 				 * dirent test below. */
 				if (ext4_rec_len_from_disk(de->rec_len,
-					sb->s_blocksize) < EXT4_DIR_REC_LEN(1))
+					sb->s_blocksize) < __EXT4_DIR_REC_LEN(1))
 					break;
 				i += ext4_rec_len_from_disk(de->rec_len,
 							    sb->s_blocksize);
@@ -441,13 +441,17 @@ int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
 	struct rb_node **p, *parent = NULL;
 	struct fname *fname, *new_fn;
 	struct dir_private_info *info;
+	int extra_data = 0;
 	int len;
 
 	info = dir_file->private_data;
 	p = &info->root.rb_node;
 
 	/* Create and allocate the fname structure */
-	len = sizeof(struct fname) + ent_name->len + 1;
+	if (dirent->file_type & EXT4_DIRENT_LUFID)
+		extra_data = ext4_get_dirent_data_len(dirent);
+
+	len = sizeof(struct fname) + ent_name->len + extra_data + 1;
 	new_fn = kzalloc(len, GFP_KERNEL);
 	if (!new_fn)
 		return -ENOMEM;
@@ -456,7 +460,7 @@ int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
 	new_fn->inode = le32_to_cpu(dirent->inode);
 	new_fn->name_len = ent_name->len;
 	new_fn->file_type = dirent->file_type;
-	memcpy(new_fn->name, ent_name->name, ent_name->len);
+	memcpy(new_fn->name, ent_name->name, ent_name->len + extra_data);
 	new_fn->name[ent_name->len] = 0;
 
 	while (*p) {
fs/ext4/ext4.h +87 -5

153 lines not on this page · raw message

fs/ext4/inline.c +8 -8
index f73bc39..7610cfe 100644
@@ -1023,7 +1023,7 @@ static int ext4_add_dirent_to_inline(handle_t *handle,
 	struct ext4_dir_entry_2 *de;
 
 	err = ext4_find_dest_de(dir, inode, iloc->bh, inline_start,
-				inline_size, fname, &de);
+				inline_size, fname, &de, NULL);
 	if (err)
 		return err;
 
@@ -1031,7 +1031,7 @@ static int ext4_add_dirent_to_inline(handle_t *handle,
 	err = ext4_journal_get_write_access(handle, iloc->bh);
 	if (err)
 		return err;
-	ext4_insert_dentry(inode, de, inline_size, fname);
+	ext4_insert_dentry(inode, de, inline_size, fname, NULL);
 
 	ext4_show_inline_dir(dir, iloc->bh, inline_start, inline_size);
 
@@ -1100,7 +1100,7 @@ static int ext4_update_inline_dir(handle_t *handle, struct inode *dir,
 	int old_size = EXT4_I(dir)->i_inline_size - EXT4_MIN_INLINE_DATA_SIZE;
 	int new_size = get_max_inline_xattr_value_size(dir, iloc);
 
-	if (new_size - old_size <= EXT4_DIR_REC_LEN(1))
+	if (new_size - old_size <= __EXT4_DIR_REC_LEN(1))
 		return -ENOSPC;
 
 	ret = ext4_update_inline_data(handle, dir,
@@ -1381,7 +1381,7 @@ int htree_inlinedir_to_tree(struct file *dir_file,
 			fake.name_len = 1;
 			strcpy(fake.name, ".");
 			fake.rec_len = ext4_rec_len_to_disk(
-						EXT4_DIR_REC_LEN(fake.name_len),
+						EXT4_DIR_REC_LEN(&fake),
 						inline_size);
 			ext4_set_de_type(inode->i_sb, &fake, S_IFDIR);
 			de = &fake;
@@ -1391,7 +1391,7 @@ int htree_inlinedir_to_tree(struct file *dir_file,
 			fake.name_len = 2;
 			strcpy(fake.name, "..");
 			fake.rec_len = ext4_rec_len_to_disk(
-						EXT4_DIR_REC_LEN(fake.name_len),
+						EXT4_DIR_REC_LEN(&fake),
 						inline_size);
 			ext4_set_de_type(inode->i_sb, &fake, S_IFDIR);
 			de = &fake;
@@ -1489,8 +1489,8 @@ int ext4_read_inline_dir(struct file *file,
 	 * So we will use extra_offset and extra_size to indicate them
 	 * during the inline dir iteration.
 	 */
-	dotdot_offset = EXT4_DIR_REC_LEN(1);
-	dotdot_size = dotdot_offset + EXT4_DIR_REC_LEN(2);
+	dotdot_offset = __EXT4_DIR_REC_LEN(1);
+	dotdot_size = dotdot_offset + __EXT4_DIR_REC_LEN(2);
 	extra_offset = dotdot_size - EXT4_INLINE_DOTDOT_SIZE;
 	extra_size = extra_offset + inline_size;
 
@@ -1525,7 +1525,7 @@ int ext4_read_inline_dir(struct file *file,
 			 * failure will be detected in the
 			 * dirent test below. */
 			if (ext4_rec_len_from_disk(de->rec_len, extra_size)
-				< EXT4_DIR_REC_LEN(1))
+				< __EXT4_DIR_REC_LEN(1))
 				break;
 			i += ext4_rec_len_from_disk(de->rec_len,
 						    extra_size);
fs/ext4/namei.c +171 -46

444 lines not on this page · raw message

fs/ext4/super.c +3 -1
index d15c26c..564eb35 100644
@@ -1447,7 +1447,7 @@ enum {
 	Opt_data_err_abort, Opt_data_err_ignore, Opt_test_dummy_encryption,
 	Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
 	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
-	Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err,
+	Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err, Opt_dirdata,
 	Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_i_version, Opt_dax,
 	Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_warn_on_error,
 	Opt_nowarn_on_error, Opt_mblk_io_submit,
@@ -1474,6 +1474,7 @@ enum {
 	{Opt_err_ro, "errors=remount-ro"},
 	{Opt_nouid32, "nouid32"},
 	{Opt_debug, "debug"},
+	{Opt_dirdata, "dirdata"},
 	{Opt_removed, "oldalloc"},
 	{Opt_removed, "orlov"},
 	{Opt_user_xattr, "user_xattr"},
@@ -1747,6 +1748,7 @@ static int clear_qf_name(struct super_block *sb, int qtype)
 	{Opt_grpjquota, 0, MOPT_Q},
 	{Opt_offusrjquota, 0, MOPT_Q},
 	{Opt_offgrpjquota, 0, MOPT_Q},
+	{Opt_dirdata, EXT4_MOUNT_DIRDATA, MOPT_SET},
 	{Opt_jqfmt_vfsold, QFMT_VFS_OLD, MOPT_QFMT},
 	{Opt_jqfmt_vfsv0, QFMT_VFS_V0, MOPT_QFMT},
 	{Opt_jqfmt_vfsv1, QFMT_VFS_V1, MOPT_QFMT},
Signature · 1 line
1.8.3.1
#25 lore raw

PATCH 11/22 ext4: over ride current_time

In reply to James Simmons

return i_ctime if IS_NOCMTIME is true for inode.

---
 fs/ext4/ext4.h | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ext4/ext4.h +7 -0
index 51b6159..80601a9 100644
@@ -661,6 +661,13 @@ enum {
 #define EXT4_GOING_FLAGS_LOGFLUSH		0x1	/* flush log but not data */
 #define EXT4_GOING_FLAGS_NOLOGFLUSH		0x2	/* don't flush log nor data */
 
+static inline struct timespec64 ext4_current_time(struct inode *inode)
+{
+	if (IS_NOCMTIME(inode))
+		return inode->i_ctime;
+	return current_time(inode);
+}
+#define current_time(a) ext4_current_time(a)
 
 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /*
Signature · 1 line
1.8.3.1
#26 lore raw

PATCH 11/22 ext4: over ride current_time

Quoted 1 line · James Simmons

return i_ctime if IS_NOCMTIME is true for inode.

So ... this prevents ext4 from ever changing the i_ctime on any file with S_NOCMTIME set - and osd-ldiskfs sets that on all inodes.

Presumably osd wants full control of the ctime.

That's probably a reasonable goal. I think it should be achieved by adding a mount/sb flag which suppresses all m/ctime updates except those made through utimes().

NeilBrown

Quoted 26 lines
---
 fs/ext4/ext4.h | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ext4/ext4.h +7 -0
index 51b6159..80601a9 100644
@@ -661,6 +661,13 @@ enum {
 #define EXT4_GOING_FLAGS_LOGFLUSH		0x1	/* flush log but not data */
 #define EXT4_GOING_FLAGS_NOLOGFLUSH		0x2	/* don't flush log nor data */
 
+static inline struct timespec64 ext4_current_time(struct inode *inode)
+{
+	if (IS_NOCMTIME(inode))
+		return inode->i_ctime;
+	return current_time(inode);
+}
+#define current_time(a) ext4_current_time(a)
 
 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /*
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/6cddc8bd/attachment.sig>

#27 lore raw

PATCH 12/22 ext4: add htree lock implementation

In reply to James Simmons

Used for parallel lookup

---
 fs/ext4/Makefile     |   4 +-
 fs/ext4/ext4.h       |  80 +++++
 fs/ext4/htree_lock.c | 891 +++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/htree_lock.h | 187 +++++++++++
 fs/ext4/namei.c      | 461 +++++++++++++++++++++++---
 fs/ext4/super.c      |   1 +
 6 files changed, 1583 insertions(+), 41 deletions(-)
 create mode 100644 fs/ext4/htree_lock.c
 create mode 100644 fs/ext4/htree_lock.h
fs/ext4/Makefile +2 -2
index 8fdfcd3..0d0a28f 100644
@@ -6,8 +6,8 @@
 obj-$(CONFIG_EXT4_FS) += ext4.o
 
 ext4-y	:= balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \
-		extents_status.o file.o fsmap.o fsync.o hash.o ialloc.o \
-		indirect.o inline.o inode.o ioctl.o mballoc.o migrate.o \
+		extents_status.o file.o fsmap.o fsync.o hash.o htree_lock.o \
+		ialloc.o indirect.o inline.o inode.o ioctl.o mballoc.o migrate.o \
 		mmp.o move_extent.o namei.o page-io.o readpage.o resize.o \
 		super.o symlink.o sysfs.o xattr.o xattr_trusted.o xattr_user.o
 
fs/ext4/ext4.h +80 -0

106 lines not on this page · raw message

fs/ext4/htree_lock.c new file +891 -0

891 lines not on this page · raw message

fs/ext4/htree_lock.h new file +187 -0

187 lines not on this page · raw message

fs/ext4/namei.c +422 -39

701 lines not on this page · raw message

fs/ext4/super.c +1 -0
index 564eb35..07242d7 100644
@@ -1077,6 +1077,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
 		return NULL;
 
 	inode_set_iversion(&ei->vfs_inode, 1);
+	sema_init(&ei->i_append_sem, 1);
 	spin_lock_init(&ei->i_raw_lock);
 	INIT_LIST_HEAD(&ei->i_prealloc_list);
 	spin_lock_init(&ei->i_prealloc_lock);
Signature · 1 line
1.8.3.1
#28 lore raw

PATCH 12/22 ext4: add htree lock implementation

Quoted 1 line · James Simmons

Used for parallel lookup

This needs more time for review than I have just now ... I suspect the full EX,PW,PR,CW,CR locking is overkill, but I won't know until I read the code (unlikely to happen this year).

Also, we need parallel lookups at the VFS level - I do have code for that.

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/4b36bb59/attachment-0001.sig>

#29 lore raw

PATCH 13/22 ext4: Add a proc interface for max_dir_size.

In reply to James Simmons
---
 fs/ext4/sysfs.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/ext4/sysfs.c +6 -0
index 1375815..3a71a16 100644
@@ -180,6 +180,8 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, inode_readahead,
 		 ext4_sb_info, s_inode_readahead_blks);
 EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
+EXT4_RW_ATTR_SBI_UI(max_dir_size, s_max_dir_size_kb);
+EXT4_RW_ATTR_SBI_UI(max_dir_size_kb, s_max_dir_size_kb);
 EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats);
 EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
 EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
@@ -210,6 +212,8 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 	ATTR_LIST(reserved_clusters),
 	ATTR_LIST(inode_readahead_blks),
 	ATTR_LIST(inode_goal),
+	ATTR_LIST(max_dir_size),
+	ATTR_LIST(max_dir_size_kb),
 	ATTR_LIST(mb_stats),
 	ATTR_LIST(mb_max_to_scan),
 	ATTR_LIST(mb_min_to_scan),
@@ -350,6 +354,8 @@ static ssize_t ext4_attr_store(struct kobject *kobj,
 		ret = kstrtoul(skip_spaces(buf), 0, &t);
 		if (ret)
 			return ret;
+		if (strcmp("max_dir_size", a->attr.name) == 0)
+			t >>= 10;
 		if (a->attr_ptr == ptr_ext4_super_block_offset)
 			*((__le32 *) ptr) = cpu_to_le32(t);
 		else
Signature · 1 line
1.8.3.1
#30 lore raw

PATCH 13/22 ext4: Add a proc interface for max_dir_size.

Quoted 10 lines · James Simmons
---
 fs/ext4/sysfs.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/ext4/sysfs.c +0 -0
index 1375815..3a71a16 100644

fs/ext4/sysfs.c static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf) · line 184

Quoted 5 lines
fs/ext4/sysfs.c +2 -0
@@ -180,6 +180,8 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, inode_readahead,
 		 ext4_sb_info, s_inode_readahead_blks);
 EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
+EXT4_RW_ATTR_SBI_UI(max_dir_size, s_max_dir_size_kb);
+EXT4_RW_ATTR_SBI_UI(max_dir_size_kb, s_max_dir_size_kb);

Why do we need both?

Quoted 13 lines
fs/ext4/sysfs.c +2 -0
 EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats);
 EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
 EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
@@ -210,6 +212,8 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 	ATTR_LIST(reserved_clusters),
 	ATTR_LIST(inode_readahead_blks),
 	ATTR_LIST(inode_goal),
+	ATTR_LIST(max_dir_size),
+	ATTR_LIST(max_dir_size_kb),
 	ATTR_LIST(mb_stats),
 	ATTR_LIST(mb_max_to_scan),
 	ATTR_LIST(mb_min_to_scan),

fs/ext4/sysfs.c static ssize_t ext4_attr_store(struct kobject *kobj, · line 358

Quoted 5 lines
fs/ext4/sysfs.c +2 -0
@@ -350,6 +354,8 @@ static ssize_t ext4_attr_store(struct kobject *kobj,
 		ret = kstrtoul(skip_spaces(buf), 0, &t);
 		if (ret)
 			return ret;
+		if (strcmp("max_dir_size", a->attr.name) == 0)
+			t >>= 10;

Give that the attrs are read/write, surely we need a <<= 10 in the read path too??

NeilBrown

Quoted 5 lines
fs/ext4/sysfs.c +0 -0
 		if (a->attr_ptr == ptr_ext4_super_block_offset)
 			*((__le32 *) ptr) = cpu_to_le32(t);
 		else
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/4565dc41/attachment.sig>

#31 lore raw

PATCH 14/22 ext4: remove inode_lock handling

In reply to James Simmons

There will cause a deadlock if invoke ext4_truncate with i_mutex locked in lustre. Since lustre has own lock to provide protect so we don't need this check at all.

---
 fs/ext4/inode.c | 2 --
 fs/ext4/namei.c | 4 ----
 2 files changed, 6 deletions(-)
fs/ext4/inode.c +0 -2
index 5561351..9296611 100644
@@ -4474,8 +4474,6 @@ int ext4_truncate(struct inode *inode)
 	 * or it's a completely new inode. In those cases we might not
 	 * have i_mutex locked because it's not necessary.
 	 */
-	if (!(inode->i_state & (I_NEW|I_FREEING)))
-		WARN_ON(!inode_is_locked(inode));
 	trace_ext4_truncate_enter(inode);
 
 	if (!ext4_can_truncate(inode))
fs/ext4/namei.c +0 -4
index 0153c4d..1b6d22a 100644
@@ -3485,8 +3485,6 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
 	if (!sbi->s_journal || is_bad_inode(inode))
 		return 0;
 
-	WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
-		     !inode_is_locked(inode));
 	/*
 	 * Exit early if inode already is on orphan list. This is a big speedup
 	 * since we don't have to contend on the global s_orphan_lock.
@@ -3569,8 +3567,6 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
 	if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS))
 		return 0;
 
-	WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
-		     !inode_is_locked(inode));
 	/* Do this quick check before taking global s_orphan_lock. */
 	if (list_empty(&ei->i_orphan))
 		return 0;
Signature · 1 line
1.8.3.1
#32 lore raw

PATCH 14/22 ext4: remove inode_lock handling

Quoted 3 lines · James Simmons

There will cause a deadlock if invoke ext4_truncate with i_mutex locked in lustre. Since lustre has own lock to provide protect so we don't need this check at all.

I guess you mean that if you took i_mutex in lustre, that would cause a deadlock?

More evidence needed, and I strongly suspect that this is a bad idea.

NeilBrown

Quoted 44 lines
---
 fs/ext4/inode.c | 2 --
 fs/ext4/namei.c | 4 ----
 2 files changed, 6 deletions(-)
fs/ext4/inode.c +0 -2
index 5561351..9296611 100644
@@ -4474,8 +4474,6 @@ int ext4_truncate(struct inode *inode)
 	 * or it's a completely new inode. In those cases we might not
 	 * have i_mutex locked because it's not necessary.
 	 */
-	if (!(inode->i_state & (I_NEW|I_FREEING)))
-		WARN_ON(!inode_is_locked(inode));
 	trace_ext4_truncate_enter(inode);
 
 	if (!ext4_can_truncate(inode))
fs/ext4/namei.c +0 -4
index 0153c4d..1b6d22a 100644
@@ -3485,8 +3485,6 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
 	if (!sbi->s_journal || is_bad_inode(inode))
 		return 0;
 
-	WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
-		     !inode_is_locked(inode));
 	/*
 	 * Exit early if inode already is on orphan list. This is a big speedup
 	 * since we don't have to contend on the global s_orphan_lock.
@@ -3569,8 +3567,6 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
 	if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS))
 		return 0;
 
-	WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
-		     !inode_is_locked(inode));
 	/* Do this quick check before taking global s_orphan_lock. */
 	if (list_empty(&ei->i_orphan))
 		return 0;
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/9e5d5f7a/attachment.sig>

#33 lore raw

PATCH 15/22 ext4: remove bitmap corruption warnings

In reply to James Simmons

Since we could skip corrupt block groups, this patch use ext4_warning() intead of ext4_error() to make FS not mount RO in default.

---
 fs/ext4/balloc.c  | 10 ++++-----
 fs/ext4/ialloc.c  |  6 ++---
 fs/ext4/mballoc.c | 66 +++++++++++++++++++++++--------------------------------
 3 files changed, 35 insertions(+), 47 deletions(-)
fs/ext4/balloc.c +5 -5
index bca75c1..aff3981 100644
@@ -374,7 +374,7 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
 	if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group,
 			desc, bh))) {
 		ext4_unlock_group(sb, block_group);
-		ext4_error(sb, "bg %u: bad block bitmap checksum", block_group);
+		ext4_warning(sb, "bg %u: bad block bitmap checksum", block_group);
 		ext4_mark_group_bitmap_corrupted(sb, block_group,
 					EXT4_GROUP_INFO_BBITMAP_CORRUPT);
 		return -EFSBADCRC;
@@ -382,8 +382,8 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
 	blk = ext4_valid_block_bitmap(sb, desc, block_group, bh);
 	if (unlikely(blk != 0)) {
 		ext4_unlock_group(sb, block_group);
-		ext4_error(sb, "bg %u: block %llu: invalid block bitmap",
-			   block_group, blk);
+		ext4_warning(sb, "bg %u: block %llu: invalid block bitmap",
+			     block_group, blk);
 		ext4_mark_group_bitmap_corrupted(sb, block_group,
 					EXT4_GROUP_INFO_BBITMAP_CORRUPT);
 		return -EFSCORRUPTED;
@@ -459,8 +459,8 @@ struct buffer_head *
 		ext4_unlock_group(sb, block_group);
 		unlock_buffer(bh);
 		if (err) {
-			ext4_error(sb, "Failed to init block bitmap for group "
-				   "%u: %d", block_group, err);
+			ext4_warning(sb, "Failed to init block bitmap for group "
+				     "%u: %d", block_group, err);
 			goto out;
 		}
 		goto verify;
fs/ext4/ialloc.c +3 -3
index 68d41e6..a72fe63 100644
@@ -96,8 +96,8 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
 	if (!ext4_inode_bitmap_csum_verify(sb, block_group, desc, bh,
 					   EXT4_INODES_PER_GROUP(sb) / 8)) {
 		ext4_unlock_group(sb, block_group);
-		ext4_error(sb, "Corrupt inode bitmap - block_group = %u, "
-			   "inode_bitmap = %llu", block_group, blk);
+		ext4_warning(sb, "Corrupt inode bitmap - block_group = %u, "
+			     "inode_bitmap = %llu", block_group, blk);
 		ext4_mark_group_bitmap_corrupted(sb, block_group,
 					EXT4_GROUP_INFO_IBITMAP_CORRUPT);
 		return -EFSBADCRC;
@@ -346,7 +346,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
 		if (!fatal)
 			fatal = err;
 	} else {
-		ext4_error(sb, "bit already cleared for inode %lu", ino);
+		ext4_warning(sb, "bit already cleared for inode %lu", ino);
 		ext4_mark_group_bitmap_corrupted(sb, block_group,
 					EXT4_GROUP_INFO_IBITMAP_CORRUPT);
 	}
fs/ext4/mballoc.c +27 -39

176 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#34 lore raw

PATCH 15/22 ext4: remove bitmap corruption warnings

Quoted 3 lines · James Simmons

Since we could skip corrupt block groups, this patch use ext4_warning() intead of ext4_error() to make FS not mount RO in default.

Does this related to the previous patch:
ext4: add extra checks for mballoc

??
If so, it seems like a good idea, but the two patches should be consecutive.
The description could read "Now that we skip corrupt ....".

NeilBrown

Quoted 265 lines
---
 fs/ext4/balloc.c  | 10 ++++-----
 fs/ext4/ialloc.c  |  6 ++---
 fs/ext4/mballoc.c | 66 +++++++++++++++++++++++--------------------------------
 3 files changed, 35 insertions(+), 47 deletions(-)
fs/ext4/balloc.c +5 -5
index bca75c1..aff3981 100644
@@ -374,7 +374,7 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
 	if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group,
 			desc, bh))) {
 		ext4_unlock_group(sb, block_group);
-		ext4_error(sb, "bg %u: bad block bitmap checksum", block_group);
+		ext4_warning(sb, "bg %u: bad block bitmap checksum", block_group);
 		ext4_mark_group_bitmap_corrupted(sb, block_group,
 					EXT4_GROUP_INFO_BBITMAP_CORRUPT);
 		return -EFSBADCRC;
@@ -382,8 +382,8 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
 	blk = ext4_valid_block_bitmap(sb, desc, block_group, bh);
 	if (unlikely(blk != 0)) {
 		ext4_unlock_group(sb, block_group);
-		ext4_error(sb, "bg %u: block %llu: invalid block bitmap",
-			   block_group, blk);
+		ext4_warning(sb, "bg %u: block %llu: invalid block bitmap",
+			     block_group, blk);
 		ext4_mark_group_bitmap_corrupted(sb, block_group,
 					EXT4_GROUP_INFO_BBITMAP_CORRUPT);
 		return -EFSCORRUPTED;
@@ -459,8 +459,8 @@ struct buffer_head *
 		ext4_unlock_group(sb, block_group);
 		unlock_buffer(bh);
 		if (err) {
-			ext4_error(sb, "Failed to init block bitmap for group "
-				   "%u: %d", block_group, err);
+			ext4_warning(sb, "Failed to init block bitmap for group "
+				     "%u: %d", block_group, err);
 			goto out;
 		}
 		goto verify;
fs/ext4/ialloc.c +3 -3
index 68d41e6..a72fe63 100644
@@ -96,8 +96,8 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
 	if (!ext4_inode_bitmap_csum_verify(sb, block_group, desc, bh,
 					   EXT4_INODES_PER_GROUP(sb) / 8)) {
 		ext4_unlock_group(sb, block_group);
-		ext4_error(sb, "Corrupt inode bitmap - block_group = %u, "
-			   "inode_bitmap = %llu", block_group, blk);
+		ext4_warning(sb, "Corrupt inode bitmap - block_group = %u, "
+			     "inode_bitmap = %llu", block_group, blk);
 		ext4_mark_group_bitmap_corrupted(sb, block_group,
 					EXT4_GROUP_INFO_IBITMAP_CORRUPT);
 		return -EFSBADCRC;
@@ -346,7 +346,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
 		if (!fatal)
 			fatal = err;
 	} else {
-		ext4_error(sb, "bit already cleared for inode %lu", ino);
+		ext4_warning(sb, "bit already cleared for inode %lu", ino);
 		ext4_mark_group_bitmap_corrupted(sb, block_group,
 					EXT4_GROUP_INFO_IBITMAP_CORRUPT);
 	}
fs/ext4/mballoc.c +27 -39
index 463fba6..82398b0 100644
@@ -741,10 +741,15 @@ int ext4_mb_generate_buddy(struct super_block *sb,
 	grp->bb_fragments = fragments;
 
 	if (free != grp->bb_free) {
-		ext4_grp_locked_error(sb, group, 0, 0,
-				      "block bitmap and bg descriptor "
-				      "inconsistent: %u vs %u free clusters",
-				      free, grp->bb_free);
+		struct ext4_group_desc *gdp;
+
+		gdp = ext4_get_group_desc(sb, group, NULL);
+		ext4_warning(sb, "group %lu: block bitmap and bg descriptor "
+			     "inconsistent: %u vs %u free clusters "
+			     "%u in gd, %lu pa's",
+			     (long unsigned int)group, free, grp->bb_free,
+			     ext4_free_group_clusters(sb, gdp),
+			     grp->bb_prealloc_nr);
 		/*
 		 * If we intend to continue, we consider group descriptor
 		 * corrupt and update bb_free using bitmap value
@@ -1106,7 +1111,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group, gfp_t gfp)
 	int block;
 	int pnum;
 	int poff;
-	struct page *page;
+	struct page *page = NULL;
 	int ret;
 	struct ext4_group_info *grp;
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -1132,7 +1137,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group, gfp_t gfp)
 		 */
 		ret = ext4_mb_init_group(sb, group, gfp);
 		if (ret)
-			return ret;
+			goto err;
 	}
 
 	/*
@@ -1235,6 +1240,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group, gfp_t gfp)
 		put_page(e4b->bd_buddy_page);
 	e4b->bd_buddy = NULL;
 	e4b->bd_bitmap = NULL;
+	ext4_warning(sb, "Error loading buddy information for %u", group);
 	return ret;
 }
 
@@ -3631,8 +3637,10 @@ int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap,
 	}
 
 	if (free != free_in_gdp) {
-		ext4_error(sb, "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n",
-			   group, free, free_in_gdp);
+		ext4_warning(sb, "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n",
+			     group, free, free_in_gdp);
+		ext4_mark_group_bitmap_corrupted(sb, group,
+						 EXT4_GROUP_INFO_BBITMAP_CORRUPT);
 		return -EIO;
 	}
 	return 0;
@@ -4015,14 +4023,6 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac)
 	 * otherwise maybe leave some free blocks unavailable, no need to BUG.
 	 */
 	if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
-		ext4_error(sb, "pa free mismatch: [pa %p] "
-				"[phy %lu] [logic %lu] [len %u] [free %u] "
-				"[error %u] [inode %lu] [freed %u]", pa,
-				(unsigned long)pa->pa_pstart,
-				(unsigned long)pa->pa_lstart,
-				(unsigned)pa->pa_len, (unsigned)pa->pa_free,
-				(unsigned)pa->pa_error, pa->pa_inode->i_ino,
-				free);
 		ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u",
 					free, pa->pa_free);
 		/*
@@ -4086,15 +4086,11 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac)
 	bitmap_bh = ext4_read_block_bitmap(sb, group);
 	if (IS_ERR(bitmap_bh)) {
 		err = PTR_ERR(bitmap_bh);
-		ext4_error(sb, "Error %d reading block bitmap for %u",
-			   err, group);
 		return 0;
 	}
 
 	err = ext4_mb_load_buddy(sb, group, &e4b);
 	if (err) {
-		ext4_warning(sb, "Error %d loading buddy information for %u",
-			     err, group);
 		put_bh(bitmap_bh);
 		return 0;
 	}
@@ -4255,17 +4251,12 @@ void ext4_discard_preallocations(struct inode *inode)
 
 		err = ext4_mb_load_buddy_gfp(sb, group, &e4b,
 					     GFP_NOFS|__GFP_NOFAIL);
-		if (err) {
-			ext4_error(sb, "Error %d loading buddy information for %u",
-				   err, group);
+		if (err)
 			return;
-		}
 
 		bitmap_bh = ext4_read_block_bitmap(sb, group);
 		if (IS_ERR(bitmap_bh)) {
 			err = PTR_ERR(bitmap_bh);
-			ext4_error(sb, "Error %d reading block bitmap for %u",
-					err, group);
 			ext4_mb_unload_buddy(&e4b);
 			continue;
 		}
@@ -4527,11 +4518,8 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac)
 		group = ext4_get_group_number(sb, pa->pa_pstart);
 		err = ext4_mb_load_buddy_gfp(sb, group, &e4b,
 					     GFP_NOFS|__GFP_NOFAIL);
-		if (err) {
-			ext4_error(sb, "Error %d loading buddy information for %u",
-				   err, group);
+		if (err)
 			continue;
-		}
 		ext4_lock_group(sb, group);
 		list_del(&pa->pa_group_list);
 		ext4_get_group_info(sb, group)->bb_prealloc_nr--;
@@ -4785,7 +4773,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
 			 * not revert pa_free back, just mark pa_error
 			 */
 			pa->pa_error++;
-			ext4_error(sb,
+			ext4_warning(sb,
 				   "Updating bitmap error: [err %d] "
 				   "[pa %p] [phy %lu] [logic %lu] "
 				   "[len %u] [free %u] [error %u] "
@@ -4796,6 +4784,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
 				   (unsigned)pa->pa_free,
 				   (unsigned)pa->pa_error,
 				   pa->pa_inode ? pa->pa_inode->i_ino : 0);
+			ext4_mark_group_bitmap_corrupted(sb, 0, 0);
 		}
 	}
 	ext4_mb_release_context(ac);
@@ -5081,7 +5070,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
 	err = ext4_mb_load_buddy_gfp(sb, block_group, &e4b,
 				     GFP_NOFS|__GFP_NOFAIL);
 	if (err)
-		goto error_return;
+		goto error_brelse;
 
 	/*
 	 * We need to make sure we don't reuse the freed block until after the
@@ -5171,8 +5160,9 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
 		goto do_more;
 	}
 error_return:
-	brelse(bitmap_bh);
 	ext4_std_error(sb, err);
+error_brelse:
+	brelse(bitmap_bh);
 	return;
 }
 
@@ -5272,7 +5262,7 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
 
 	err = ext4_mb_load_buddy(sb, block_group, &e4b);
 	if (err)
-		goto error_return;
+		goto error_brelse;
 
 	/*
 	 * need to update group_info->bb_free and bitmap
@@ -5310,8 +5300,9 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
 		err = ret;
 
 error_return:
-	brelse(bitmap_bh);
 	ext4_std_error(sb, err);
+error_brelse:
+	brelse(bitmap_bh);
 	return err;
 }
 
@@ -5386,11 +5377,8 @@ static int ext4_trim_extent(struct super_block *sb, int start, int count,
 	trace_ext4_trim_all_free(sb, group, start, max);
 
 	ret = ext4_mb_load_buddy(sb, group, &e4b);
-	if (ret) {
-		ext4_warning(sb, "Error %d loading buddy information for %u",
-			     ret, group);
+	if (ret)
 		return ret;
-	}
 	bitmap = e4b.bd_bitmap;
 
 	ext4_lock_group(sb, group);
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/2a84fac1/attachment.sig>

#35 lore raw

PATCH 16/22 ext4: add warning for directory htree growth

In reply to James Simmons
---
 fs/ext4/ext4.h  |  1 +
 fs/ext4/namei.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 fs/ext4/super.c |  2 ++
 fs/ext4/sysfs.c |  2 ++
 4 files changed, 72 insertions(+), 2 deletions(-)
fs/ext4/ext4.h +1 -0
index bf74c7c..5f73e19 100644
@@ -1472,6 +1472,7 @@ struct ext4_sb_info {
 	unsigned int s_mb_group_prealloc;
 	unsigned long *s_mb_prealloc_table;
 	unsigned int s_max_dir_size_kb;
+	unsigned long s_warning_dir_size;
 	/* where last allocation was done - for stream allocation */
 	unsigned long s_mb_last_group;
 	unsigned long s_mb_last_start;
fs/ext4/namei.c +67 -2

103 lines not on this page · raw message

fs/ext4/super.c +2 -0
index 07242d7..a3179b2 100644
@@ -1901,6 +1901,8 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
 		sbi->s_li_wait_mult = arg;
 	} else if (token == Opt_max_dir_size_kb) {
 		sbi->s_max_dir_size_kb = arg;
+		/* reset s_warning_dir_size and make it re-calculated */
+		sbi->s_warning_dir_size = 0;
 	} else if (token == Opt_stripe) {
 		sbi->s_stripe = arg;
 	} else if (token == Opt_resuid) {
fs/ext4/sysfs.c +2 -0
index 3a71a16..575f318 100644
@@ -182,6 +182,7 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
 EXT4_RW_ATTR_SBI_UI(max_dir_size, s_max_dir_size_kb);
 EXT4_RW_ATTR_SBI_UI(max_dir_size_kb, s_max_dir_size_kb);
+EXT4_RW_ATTR_SBI_UI(warning_dir_size, s_warning_dir_size);
 EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats);
 EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
 EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
@@ -214,6 +215,7 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 	ATTR_LIST(inode_goal),
 	ATTR_LIST(max_dir_size),
 	ATTR_LIST(max_dir_size_kb),
+	ATTR_LIST(warning_dir_size),
 	ATTR_LIST(mb_stats),
 	ATTR_LIST(mb_max_to_scan),
 	ATTR_LIST(mb_min_to_scan),
Signature · 1 line
1.8.3.1
#36 lore raw

PATCH 16/22 ext4: add warning for directory htree growth

On Sun, Jul 21 2019, James Simmons wrote:

You have really out-done yourself with the commit message here !!!

I think this allows lustre to generate warnings if any single directory exceeds some particular size ??
Any be default, the max size is 33% larger than the first directory that anything is added to??
I guess lustre just uses one big directory??

I appreciate that this might be useful functionality. I suspect a better interface is needed.

NeilBrown

Quoted 167 lines
---
 fs/ext4/ext4.h  |  1 +
 fs/ext4/namei.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 fs/ext4/super.c |  2 ++
 fs/ext4/sysfs.c |  2 ++
 4 files changed, 72 insertions(+), 2 deletions(-)
fs/ext4/ext4.h +1 -0
index bf74c7c..5f73e19 100644
@@ -1472,6 +1472,7 @@ struct ext4_sb_info {
 	unsigned int s_mb_group_prealloc;
 	unsigned long *s_mb_prealloc_table;
 	unsigned int s_max_dir_size_kb;
+	unsigned long s_warning_dir_size;
 	/* where last allocation was done - for stream allocation */
 	unsigned long s_mb_last_group;
 	unsigned long s_mb_last_start;
fs/ext4/namei.c +67 -2
index 1b6d22a..9b30cc6 100644
@@ -757,12 +757,20 @@ struct ext4_dir_lock_data {
 #define ext4_htree_lock_data(l)	((struct ext4_dir_lock_data *)(l)->lk_private)
 #define ext4_find_entry(dir, name, dirent, inline) \
 			ext4_find_entry_locked(dir, name, dirent, inline, NULL)
-#define ext4_add_entry(handle, dentry, inode) \
-		       ext4_add_entry_locked(handle, dentry, inode, NULL)
 
 /* NB: ext4_lblk_t is 32 bits so we use high bits to identify invalid blk */
 #define EXT4_HTREE_NODE_CHANGED		(0xcafeULL << 32)
 
+inline int ext4_add_entry(handle_t *handle, struct dentry *dentry,
+			  struct inode *inode)
+{
+	int ret = ext4_add_entry_locked(handle, dentry, inode, NULL);
+
+	if (ret == -ENOBUFS)
+		ret = 0;
+	return ret;
+}
+
 static void ext4_htree_event_cb(void *target, void *event)
 {
 	u64 *block = (u64 *)target;
@@ -2612,6 +2620,55 @@ static int ext4_update_dotdot(handle_t *handle, struct dentry *dentry,
 	return err;
 }
 
+static unsigned long __ext4_max_dir_size(struct dx_frame *frames,
+					 struct dx_frame *frame,
+					 struct inode *dir)
+{
+	unsigned long max_dir_size;
+
+	if (EXT4_SB(dir->i_sb)->s_max_dir_size_kb) {
+		max_dir_size = EXT4_SB(dir->i_sb)->s_max_dir_size_kb << 10;
+	} else {
+		max_dir_size = EXT4_BLOCK_SIZE(dir->i_sb);
+		while (frame >= frames) {
+			max_dir_size *= dx_get_limit(frame->entries);
+			if (frame == frames)
+				break;
+			frame--;
+		}
+		/* use 75% of max dir size in average */
+		max_dir_size = max_dir_size / 4 * 3;
+	}
+	return max_dir_size;
+}
+
+/*
+ * With hash tree growing, it is easy to hit ENOSPC, but it is hard
+ * to predict when it will happen. let's give administrators warning
+ * when reaching 3/5 and 2/3 of limit
+ */
+static inline bool dir_size_in_warning_range(struct dx_frame *frames,
+					     struct dx_frame *frame,
+					     struct inode *dir)
+{
+	struct super_block *sb = dir->i_sb;
+	unsigned long size1, size2;
+
+	if (unlikely(!EXT4_SB(sb)->s_warning_dir_size))
+		EXT4_SB(sb)->s_warning_dir_size =
+			__ext4_max_dir_size(frames, frame, dir);
+
+	size1 = EXT4_SB(sb)->s_warning_dir_size / 16 * 10;
+	size1 = size1 & ~(EXT4_BLOCK_SIZE(sb) - 1);
+	size2 = EXT4_SB(sb)->s_warning_dir_size / 16 * 11;
+	size2 = size2 & ~(EXT4_BLOCK_SIZE(sb) - 1);
+	if (in_range(dir->i_size, size1, EXT4_BLOCK_SIZE(sb)) ||
+	    in_range(dir->i_size, size2, EXT4_BLOCK_SIZE(sb)))
+		return true;
+
+	return false;
+}
+
 /*
  *	ext4_add_entry()
  *
@@ -2739,6 +2796,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
 	struct buffer_head *bh;
 	struct super_block *sb = dir->i_sb;
 	struct ext4_dir_entry_2 *de;
+	bool ret_warn = false;
 	int restart;
 	int err;
 
@@ -2769,6 +2827,11 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
 	/* Block full, should compress but for now just split */
 	dxtrace(printk(KERN_DEBUG "using %u of %u node entries\n",
 		       dx_get_count(entries), dx_get_limit(entries)));
+
+	if (frame - frames + 1 >= ext4_dir_htree_level(sb) ||
+	    EXT4_SB(sb)->s_warning_dir_size)
+		ret_warn = dir_size_in_warning_range(frames, frame, dir);
+
 	/* Need to split index? */
 	if (dx_get_count(entries) == dx_get_limit(entries)) {
 		ext4_lblk_t newblock;
@@ -2935,6 +2998,8 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
 	 */
 	if (restart && err == 0)
 		goto again;
+	if (err == 0 && ret_warn)
+		err = -ENOBUFS;
 	return err;
 }
 
fs/ext4/super.c +2 -0
index 07242d7..a3179b2 100644
@@ -1901,6 +1901,8 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
 		sbi->s_li_wait_mult = arg;
 	} else if (token == Opt_max_dir_size_kb) {
 		sbi->s_max_dir_size_kb = arg;
+		/* reset s_warning_dir_size and make it re-calculated */
+		sbi->s_warning_dir_size = 0;
 	} else if (token == Opt_stripe) {
 		sbi->s_stripe = arg;
 	} else if (token == Opt_resuid) {
fs/ext4/sysfs.c +2 -0
index 3a71a16..575f318 100644
@@ -182,6 +182,7 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
 EXT4_RW_ATTR_SBI_UI(max_dir_size, s_max_dir_size_kb);
 EXT4_RW_ATTR_SBI_UI(max_dir_size_kb, s_max_dir_size_kb);
+EXT4_RW_ATTR_SBI_UI(warning_dir_size, s_warning_dir_size);
 EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats);
 EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
 EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
@@ -214,6 +215,7 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 	ATTR_LIST(inode_goal),
 	ATTR_LIST(max_dir_size),
 	ATTR_LIST(max_dir_size_kb),
+	ATTR_LIST(warning_dir_size),
 	ATTR_LIST(mb_stats),
 	ATTR_LIST(mb_max_to_scan),
 	ATTR_LIST(mb_min_to_scan),
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/e1069c6e/attachment-0001.sig>

#37 lore raw

PATCH 17/22 ext4: optimize ext4_journal_callback_add

In reply to James Simmons

Change list_add_tail to list_add. It gives advantages to ldiskfs in tgt_cb_last_committed. In the beginning of list will be placed thandles with the highest transaction numbers. So at the first iterations we will have the highest transno. It will save from extra call of ptlrpc_commit_replies.

---
 fs/ext4/ext4_jbd2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4_jbd2.h +1 -1
index 75a5309..5ebf8ee 100644
@@ -169,7 +169,7 @@ static inline void _ext4_journal_callback_add(handle_t *handle,
 			struct ext4_journal_cb_entry *jce)
 {
 	/* Add the jce to transaction's private list */
-	list_add_tail(&jce->jce_list, &handle->h_transaction->t_private_list);
+	list_add(&jce->jce_list, &handle->h_transaction->t_private_list);
 }
 
 static inline void ext4_journal_callback_add(handle_t *handle,
Signature · 1 line
1.8.3.1
#38 lore raw

PATCH 17/22 ext4: optimize ext4_journal_callback_add

Quoted 5 lines · James Simmons

Change list_add_tail to list_add. It gives advantages to ldiskfs in tgt_cb_last_committed. In the beginning of list will be placed thandles with the highest transaction numbers. So at the first iterations we will have the highest transno. It will save from extra call of ptlrpc_commit_replies.

If only more commit messages were like this !! Thanks!

I suspect it would be better for that thing that needs to see the highest transno first, to find a way to look at the end of the list instead of the beginning.

This isn't the sort of change that can land in ext4.

NeilBrown

Quoted 21 lines
---
 fs/ext4/ext4_jbd2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4_jbd2.h +1 -1
index 75a5309..5ebf8ee 100644
@@ -169,7 +169,7 @@ static inline void _ext4_journal_callback_add(handle_t *handle,
 			struct ext4_journal_cb_entry *jce)
 {
 	/* Add the jce to transaction's private list */
-	list_add_tail(&jce->jce_list, &handle->h_transaction->t_private_list);
+	list_add(&jce->jce_list, &handle->h_transaction->t_private_list);
 }
 
 static inline void ext4_journal_callback_add(handle_t *handle,
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/2504564a/attachment.sig>

#39 lore raw

PATCH 17/22 ext4: optimize ext4_journal_callback_add

This might be accommodated by a new API variant that allows the caller to add this commit callback at the head of the list instead of the tail.

The main question is whether such an API would be accepted upstream without a user?

Cheers, Andreas

Quoted 42 lines · NeilBrown
Quoted 8 lines · James Simmons

Change list_add_tail to list_add. It gives advantages to ldiskfs in tgt_cb_last_committed. In the beginning of list will be placed thandles with the highest transaction numbers. So at the first iterations we will have the highest transno. It will save from extra call of ptlrpc_commit_replies.

If only more commit messages were like this !! Thanks!

I suspect it would be better for that thing that needs to see the highest transno first, to find a way to look at the end of the list instead of the beginning.

This isn't the sort of change that can land in ext4.

NeilBrown

Quoted 21 lines

---
fs/ext4/ext4_jbd2.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4_jbd2.h +1 -1
index 75a5309..5ebf8ee 100644
@@ -169,7 +169,7 @@ static inline void _ext4_journal_callback_add(handle_t *handle,
           struct ext4_journal_cb_entry *jce)
 {
   /* Add the jce to transaction's private list */
-    list_add_tail(&jce->jce_list, &handle->h_transaction->t_private_list);
+    list_add(&jce->jce_list, &handle->h_transaction->t_private_list);
 }
 
 static inline void ext4_journal_callback_add(handle_t *handle,
Signature · 1 line
1.8.3.1
#40 lore raw

PATCH 18/22 ext4: attach jinode in writepages

In reply to James Simmons
---
 fs/ext4/ext4.h  | 1 +
 fs/ext4/inode.c | 7 +++++++
 2 files changed, 8 insertions(+)
fs/ext4/ext4.h +1 -0
index 5f73e19..0ee4606 100644
@@ -2643,6 +2643,7 @@ extern int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
 extern void ext4_process_freed_data(struct super_block *sb, tid_t commit_tid);
 
 /* inode.c */
+#define HAVE_LDISKFS_INFO_JINODE
 int ext4_inode_is_fast_symlink(struct inode *inode);
 struct buffer_head *ext4_getblk(handle_t *, struct inode *, ext4_lblk_t, int);
 struct buffer_head *ext4_bread(handle_t *, struct inode *, ext4_lblk_t, int);
fs/ext4/inode.c +7 -0
index 9296611..bf00dfc 100644
@@ -731,6 +731,9 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
 		    !(flags & EXT4_GET_BLOCKS_ZERO) &&
 		    !ext4_is_quota_file(inode) &&
 		    ext4_should_order_data(inode)) {
+			ret = ext4_inode_attach_jinode(inode);
+			if (ret)
+				return ret;
 			if (flags & EXT4_GET_BLOCKS_IO_SUBMIT)
 				ret = ext4_jbd2_inode_add_wait(handle, inode);
 			else
@@ -2815,6 +2818,9 @@ static int ext4_writepages(struct address_space *mapping,
 		mpd.last_page = wbc->range_end >> PAGE_SHIFT;
 	}
 
+	ret = ext4_inode_attach_jinode(inode);
+	if (ret)
+		return ret;
 	mpd.inode = inode;
 	mpd.wbc = wbc;
 	ext4_io_submit_init(&mpd.io_submit, wbc);
@@ -4432,6 +4438,7 @@ int ext4_inode_attach_jinode(struct inode *inode)
 		jbd2_free_inode(jinode);
 	return 0;
 }
+EXPORT_SYMBOL(ext4_inode_attach_jinode);
 
 /*
  * ext4_truncate()
Signature · 1 line
1.8.3.1
#41 lore raw

PATCH 19/22 ext4: don't check before replay

In reply to James Simmons

When ldiskfs run in failover mode whith read-only disk. Part of allocation updates are lost and ldiskfs may fail while mounting this is due to inconsistent state of group-descriptor. Group-descriptor check is added after journal replay.

---
 fs/ext4/super.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/super.c +6 -5
index a3179b2..b818acb 100644
@@ -4255,11 +4255,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		}
 	}
 	sbi->s_gdb_count = db_count;
-	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
-		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
-		ret = -EFSCORRUPTED;
-		goto failed_mount2;
-	}
 
 	timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
 
@@ -4401,6 +4396,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
 
 no_journal:
+	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
+		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
+		ret = -EFSCORRUPTED;
+		goto failed_mount_wq;
+	}
+
 	if (!test_opt(sb, NO_MBCACHE)) {
 		sbi->s_ea_block_cache = ext4_xattr_create_cache();
 		if (!sbi->s_ea_block_cache) {
Signature · 1 line
1.8.3.1
#42 lore raw

PATCH 19/22 ext4: don't check before replay

Quoted 5 lines · James Simmons

When ldiskfs run in failover mode whith read-only disk. Part of allocation updates are lost and ldiskfs may fail while mounting this is due to inconsistent state of group-descriptor. Group-descriptor check is added after journal replay.

I think this needs to be enabled by a mount option or super-block flag.

NeilBrown

Quoted 37 lines
---
 fs/ext4/super.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/super.c +6 -5
index a3179b2..b818acb 100644
@@ -4255,11 +4255,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		}
 	}
 	sbi->s_gdb_count = db_count;
-	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
-		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
-		ret = -EFSCORRUPTED;
-		goto failed_mount2;
-	}
 
 	timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
 
@@ -4401,6 +4396,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
 
 no_journal:
+	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
+		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
+		ret = -EFSCORRUPTED;
+		goto failed_mount_wq;
+	}
+
 	if (!test_opt(sb, NO_MBCACHE)) {
 		sbi->s_ea_block_cache = ext4_xattr_create_cache();
 		if (!sbi->s_ea_block_cache) {
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/74704b19/attachment.sig>

A message that is not in the archive (sent off-list or not yet received): [email protected]

#44 lore raw

PATCH 19/22 ext4: don't check before replay

Quoted 4 lines · Alexey Lyashkov

Why?
Purpose of this patch is simple and don?t addressed a failover in general.
Crash can occurred in commit time - when journal _partially_ flushed to the FS. Checking any FS metadata in this time is wrong, because we have no guarantee to be consistence. But checking an after journal replay is fine, it check have verification no corruption hit and FS is fine.

If the corruption can occur in non-ldiskfs usage, and would be fixed by a journal replay, then yes - the patch looks like a good idea.

Possibly I misunderstood the source of the corruption... maybe if that could be made clearer in the commit message, that would help.

Thanks,
NeilBrown

Quoted 42 lines
Quoted 42 lines

22 ???? 2019 ?., ? 8:29, NeilBrown <[email protected]> ???????(?):

Quoted 5 lines · James Simmons

When ldiskfs run in failover mode whith read-only disk. Part of allocation updates are lost and ldiskfs may fail while mounting this is due to inconsistent state of group-descriptor. Group-descriptor check is added after journal replay.

I think this needs to be enabled by a mount option or super-block flag.

NeilBrown

Quoted 25 lines

---
fs/ext4/super.c | 11 ++++++-----

1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/super.c +0 -5
index a3179b2..b818acb 100644
@@ -4255,11 +4255,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		}
 	}
 	sbi->s_gdb_count = db_count;
-	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
-		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
-		ret = -EFSCORRUPTED;
-		goto failed_mount2;
-	}
 
 	timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
 
@@ -4401,6 +4396,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
 
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines

no_journal:

fs/ext4/super.c +6 -0
+	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
+		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
+		ret = -EFSCORRUPTED;
+		goto failed_mount_wq;
+	}
+
	if (!test_opt(sb, NO_MBCACHE)) {
Quoted 8 lines
Quoted 4 lines
		sbi->s_ea_block_cache = ext4_xattr_create_cache();
		if (!sbi->s_ea_block_cache) {
Signature · 1 line
1.8.3.1

_______________________________________________
lustre-devel mailing list
lustre-devel at lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/a8b8b2a4/attachment.sig>

#45 lore raw

PATCH 19/22 ext4: don't check before replay

Quoted 11 lines · NeilBrown
Quoted 4 lines · Alexey Lyashkov

Why?
Purpose of this patch is simple and don?t addressed a failover in general.
Crash can occurred in commit time - when journal _partially_ flushed to the FS. Checking any FS metadata in this time is wrong, because we have no guarantee to be consistence. But checking an after journal replay is fine, it check have verification no corruption hit and FS is fine.

Quoted 5 lines

If the corruption can occur in non-ldiskfs usage, and would be fixed by a journal replay, then yes - the patch looks like a good idea.

Possibly I misunderstood the source of the corruption... maybe if that could be made clearer in the commit message, that would help.

I think the argument is: wtf do we even look at metadata (or anything, really) before journal replay.
The patch is actually good because it does move the read after the journal replay though?

Quoted 59 lines
Quoted 59 lines
Quoted 59 lines

22 ???? 2019 ?., ? 8:29, NeilBrown <[email protected]> ???????(?):

Quoted 5 lines · James Simmons

When ldiskfs run in failover mode whith read-only disk. Part of allocation updates are lost and ldiskfs may fail while mounting this is due to inconsistent state of group-descriptor. Group-descriptor check is added after journal replay.

I think this needs to be enabled by a mount option or super-block flag.

NeilBrown

Quoted 32 lines

---
fs/ext4/super.c | 11 ++++++-----

1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/super.c +0 -5
index a3179b2..b818acb 100644
@@ -4255,11 +4255,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		}
 	}
 	sbi->s_gdb_count = db_count;
-	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
-		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
-		ret = -EFSCORRUPTED;
-		goto failed_mount2;
-	}
 
 	timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
 
@@ -4401,6 +4396,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
 

no_journal:

fs/ext4/super.c +6 -0
+	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
+		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
+		ret = -EFSCORRUPTED;
+		goto failed_mount_wq;
+	}
+
Quoted 5 lines
	if (!test_opt(sb, NO_MBCACHE)) {
		sbi->s_ea_block_cache = ext4_xattr_create_cache();
		if (!sbi->s_ea_block_cache) {
Signature · 1 line
1.8.3.1

_______________________________________________
lustre-devel mailing list
lustre-devel at lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

#46 lore raw

PATCH 19/22 ext4: don't check before replay

Quoted 16 lines

22 ???? 2019 ?., ? 9:56, Oleg Drokin <[email protected]> ???????(?):

Quoted 11 lines · NeilBrown
Quoted 4 lines · Alexey Lyashkov

Why?
Purpose of this patch is simple and don?t addressed a failover in general.
Crash can occurred in commit time - when journal _partially_ flushed to the FS. Checking any FS metadata in this time is wrong, because we have no guarantee to be consistence. But checking an after journal replay is fine, it check have verification no corruption hit and FS is fine.

If the corruption can occur in non-ldiskfs usage, and would be fixed by a journal replay, then yes - the patch looks like a good idea.

Yes, bug should fixed by journal replay. BUT this check was run _before_ journal replay and patch move groups check _after_ journal replay done.

Quoted 8 lines
Quoted 3 lines

Possibly I misunderstood the source of the corruption... maybe if that could be made clearer in the commit message, that would help.

I think the argument is: wtf do we even look at metadata (or anything, really) before journal replay.
The patch is actually good because it does move the read after the journal replay though?

Oleg,

you are right.

Quoted 66 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines

22 ???? 2019 ?., ? 8:29, NeilBrown <[email protected]> ???????(?):

Quoted 5 lines · James Simmons

When ldiskfs run in failover mode whith read-only disk. Part of allocation updates are lost and ldiskfs may fail while mounting this is due to inconsistent state of group-descriptor. Group-descriptor check is added after journal replay.

I think this needs to be enabled by a mount option or super-block flag.

NeilBrown

Quoted 25 lines

---
fs/ext4/super.c | 11 ++++++-----

1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/super.c +0 -5
index a3179b2..b818acb 100644
@@ -4255,11 +4255,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		}
 	}
 	sbi->s_gdb_count = db_count;
-	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
-		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
-		ret = -EFSCORRUPTED;
-		goto failed_mount2;
-	}
 
 	timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
 
@@ -4401,6 +4396,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
 
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

no_journal:

fs/ext4/super.c +6 -0
+	if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
+		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
+		ret = -EFSCORRUPTED;
+		goto failed_mount_wq;
+	}
+
	if (!test_opt(sb, NO_MBCACHE)) {
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
		sbi->s_ea_block_cache = ext4_xattr_create_cache();
		if (!sbi->s_ea_block_cache) {
Signature · 1 line
1.8.3.1

_______________________________________________
lustre-devel mailing list
lustre-devel at lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

_______________________________________________
lustre-devel mailing list
lustre-devel at lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

#47 lore raw

PATCH 19/22 ext4: don't check before replay

In reply to NeilBrown

Actually, I think this patch would be OK to push upstream.

Cheers, Andreas

Quoted 52 lines · NeilBrown
Quoted 8 lines · James Simmons

When ldiskfs run in failover mode whith read-only disk. Part of allocation updates are lost and ldiskfs may fail while mounting this is due to inconsistent state of group-descriptor. Group-descriptor check is added after journal replay.

I think this needs to be enabled by a mount option or super-block flag.

NeilBrown

Quoted 37 lines

---
fs/ext4/super.c | 11 ++++++-----

1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/super.c +0 -5
index a3179b2..b818acb 100644
@@ -4255,11 +4255,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
       }
   }
   sbi->s_gdb_count = db_count;
-    if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
-        ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
-        ret = -EFSCORRUPTED;
-        goto failed_mount2;
-    }
 
   timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
 
@@ -4401,6 +4396,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
   sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
 

no_journal:

fs/ext4/super.c +6 -0
+    if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
+        ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
+        ret = -EFSCORRUPTED;
+        goto failed_mount_wq;
+    }
+
   if (!test_opt(sb, NO_MBCACHE)) {
       sbi->s_ea_block_cache = ext4_xattr_create_cache();
       if (!sbi->s_ea_block_cache) {
Signature · 1 line
1.8.3.1
#48 lore raw

PATCH 19/22 ext4: don't check before replay

what I think needs to happen is a better description.

Something like:

In a crash group descriptors might not be written completely in place that would lead to FS error message on subsequent mount.

Move the check to after journal replay to ensure we are dealing with up to date (and hopefully correct) information before declaring the FS as bad.

Quoted 58 lines · Andreas Dilger

Actually, I think this patch would be OK to push upstream.

Cheers, Andreas

Quoted 52 lines · NeilBrown
Quoted 8 lines · James Simmons

When ldiskfs run in failover mode whith read-only disk. Part of allocation updates are lost and ldiskfs may fail while mounting this is due to inconsistent state of group-descriptor. Group-descriptor check is added after journal replay.

I think this needs to be enabled by a mount option or super-block flag.

NeilBrown

Quoted 37 lines

---
fs/ext4/super.c | 11 ++++++-----

1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/super.c +0 -5
index a3179b2..b818acb 100644
@@ -4255,11 +4255,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
      }
  }
  sbi->s_gdb_count = db_count;
-    if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
-        ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
-        ret = -EFSCORRUPTED;
-        goto failed_mount2;
-    }
 
  timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
 
@@ -4401,6 +4396,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
  sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
 

no_journal:

fs/ext4/super.c +6 -0
+    if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
+        ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
+        ret = -EFSCORRUPTED;
+        goto failed_mount_wq;
+    }
+
  if (!test_opt(sb, NO_MBCACHE)) {
      sbi->s_ea_block_cache = ext4_xattr_create_cache();
      if (!sbi->s_ea_block_cache) {
Signature · 1 line
1.8.3.1
#49 lore raw

PATCH 20/22 ext4: use GFP_NOFS in ext4_inode_attach_jinode

In reply to James Simmons
---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
index bf00dfc..ca72097 100644
@@ -4422,7 +4422,7 @@ int ext4_inode_attach_jinode(struct inode *inode)
 	if (ei->jinode || !EXT4_SB(inode->i_sb)->s_journal)
 		return 0;
 
-	jinode = jbd2_alloc_inode(GFP_KERNEL);
+	jinode = jbd2_alloc_inode(GFP_NOFS);
 	spin_lock(&inode->i_lock);
 	if (!ei->jinode) {
 		if (!jinode) {
Signature · 1 line
1.8.3.1
#50 lore raw

PATCH 20/22 ext4: use GFP_NOFS in ext4_inode_attach_jinode

On Sun, Jul 21 2019, James Simmons wrote:

If you need to call this from a context where GFP_KERNEL is not safe, use memalloc_nofs_{save,restore}().

NeilBrown

Quoted 20 lines
---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
index bf00dfc..ca72097 100644
@@ -4422,7 +4422,7 @@ int ext4_inode_attach_jinode(struct inode *inode)
 	if (ei->jinode || !EXT4_SB(inode->i_sb)->s_journal)
 		return 0;
 
-	jinode = jbd2_alloc_inode(GFP_KERNEL);
+	jinode = jbd2_alloc_inode(GFP_NOFS);
 	spin_lock(&inode->i_lock);
 	if (!ei->jinode) {
 		if (!jinode) {
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190722/24edb3a2/attachment.sig>

#51 lore raw

PATCH 20/22 ext4: use GFP_NOFS in ext4_inode_attach_jinode

That interface has only existed for a handful of kernel releases, so was/is not a viable option for earlier kernels.

Cheers, Andreas

Quoted 31 lines · NeilBrown

On Sun, Jul 21 2019, James Simmons wrote:

If you need to call this from a context where GFP_KERNEL is not safe, use memalloc_nofs_{save,restore}().

NeilBrown

Quoted 20 lines

---
fs/ext4/inode.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
index bf00dfc..ca72097 100644
@@ -4422,7 +4422,7 @@ int ext4_inode_attach_jinode(struct inode *inode)
   if (ei->jinode || !EXT4_SB(inode->i_sb)->s_journal)
       return 0;
 
-    jinode = jbd2_alloc_inode(GFP_KERNEL);
+    jinode = jbd2_alloc_inode(GFP_NOFS);
   spin_lock(&inode->i_lock);
   if (!ei->jinode) {
       if (!jinode) {
Signature · 1 line
1.8.3.1
#52 lore raw

PATCH 21/22 ext4: export ext4_orphan_add

In reply to James Simmons
---
 fs/ext4/namei.c | 1 +
 1 file changed, 1 insertion(+)
fs/ext4/namei.c +1 -0
index 9b30cc6..6cb3f63 100644
@@ -3615,6 +3615,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
 	ext4_std_error(sb, err);
 	return err;
 }
+EXPORT_SYMBOL(ext4_orphan_add);
 
 /*
  * ext4_orphan_del() removes an unlinked or truncated inode from the list
Signature · 1 line
1.8.3.1
#53 lore raw

PATCH 22/22 ext4: export mb stream allocator variables

In reply to James Simmons
---
 fs/ext4/ext4.h    |  2 ++
 fs/ext4/mballoc.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/sysfs.c   |  4 ++++
 3 files changed, 65 insertions(+)
fs/ext4/ext4.h +2 -0
index 0ee4606..46f2619 100644
@@ -2620,6 +2620,8 @@ extern int ext4_init_inode_table(struct super_block *sb,
 /* mballoc.c */
 extern const struct file_operations ext4_seq_prealloc_table_fops;
 extern const struct seq_operations ext4_mb_seq_groups_ops;
+extern const struct file_operations ext4_seq_mb_last_group_fops;
+extern int ext4_mb_seq_last_start_seq_show(struct seq_file *m, void *v);
 extern long ext4_mb_stats;
 extern long ext4_mb_max_to_scan;
 extern int ext4_mb_init(struct super_block *);
fs/ext4/mballoc.c +59 -0

65 lines not on this page · raw message

fs/ext4/sysfs.c +4 -0
index 575f318..6bcb455 100644
@@ -425,6 +425,10 @@ int ext4_register_sysfs(struct super_block *sb)
 				&ext4_mb_seq_groups_ops, sb);
 		proc_create_data("prealloc_table", S_IRUGO, sbi->s_proc,
 				 &ext4_seq_prealloc_table_fops, sb);
+		proc_create_data("mb_last_group", S_IRUGO, sbi->s_proc,
+				 &ext4_seq_mb_last_group_fops, sb);
+		proc_create_single_data("mb_last_start", S_IRUGO, sbi->s_proc,
+					ext4_mb_seq_last_start_seq_show, sb);
 	}
 	return 0;
 }
Signature · 1 line
1.8.3.1