Skip to contentSkip to conversation

f2fs: drop calling alloc_nid_failed when no nid is allocated

PATCH In review Kinglong Mee 2 participants 4 messages Feb 25, 2017 – Feb 27, 2017 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 f2fs: drop calling alloc_nid_failed when no nid is allocated

If hsize is less than or equal to inlien_size, and i_xattr_nid is valid, the new_nid is not allocated (no alloc_nid is called).

       if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
                if (!alloc_nid(sbi, &new_nid))
                        return -ENOSPC;

Although it's harmless calling alloc_nid_failed, it's better drop them.

---
 fs/f2fs/xattr.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/f2fs/xattr.c +4 -5
index 7298a44..fd9dc99 100644
@@ -428,19 +428,18 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
 		/* no need to use xattr node block */
 		if (hsize <= inline_size) {
 			err = truncate_xattr_node(inode, ipage);
-			alloc_nid_failed(sbi, new_nid);
+			f2fs_bug_on(sbi, new_nid);
 			return err;
 		}
 	}
 
 	/* write to xattr node block */
 	if (F2FS_I(inode)->i_xattr_nid) {
+		f2fs_bug_on(sbi, new_nid);
 		xpage = get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
-		if (IS_ERR(xpage)) {
-			alloc_nid_failed(sbi, new_nid);
+		if (IS_ERR(xpage))
 			return PTR_ERR(xpage);
-		}
-		f2fs_bug_on(sbi, new_nid);
+
 		f2fs_wait_on_page_writeback(xpage, NODE, true);
 	} else {
 		struct dnode_of_data dn;
Signature · 6 lines
2.9.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
#1 lore raw
Quoted 19 lines · Kinglong Mee

If hsize is less than or equal to inlien_size, and i_xattr_nid is valid, the new_nid is not allocated (no alloc_nid is called).

       if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
                if (!alloc_nid(sbi, &new_nid))
                        return -ENOSPC;

Although it's harmless calling alloc_nid_failed, it's better drop them.

---
 fs/f2fs/xattr.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/f2fs/xattr.c +0 -0
index 7298a44..fd9dc99 100644

fs/f2fs/xattr.c static inline int write_all_xattrs(struct inode *inode, __u32 hsize, · line 431

Quoted 4 lines
fs/f2fs/xattr.c +0 -1
@@ -428,19 +428,18 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
 		/* no need to use xattr node block */
 		if (hsize <= inline_size) {
 			err = truncate_xattr_node(inode, ipage);
-			alloc_nid_failed(sbi, new_nid);

Should keep this since new_nid was assigned above?

Quoted 5 lines
fs/f2fs/xattr.c +1 -0
+			f2fs_bug_on(sbi, new_nid);
 			return err;
 		}
 	}
 

fs/f2fs/xattr.c static inline int write_all_xattrs(struct inode *inode, __u32 hsize, · line 443

Quoted 10 lines
fs/f2fs/xattr.c +2 -4
 	/* write to xattr node block */
 	if (F2FS_I(inode)->i_xattr_nid) {
+		f2fs_bug_on(sbi, new_nid);
 		xpage = get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
-		if (IS_ERR(xpage)) {
-			alloc_nid_failed(sbi, new_nid);
+		if (IS_ERR(xpage))
 			return PTR_ERR(xpage);
-		}
-		f2fs_bug_on(sbi, new_nid);

Cleanup here looks good to me.

Thanks,

fs/f2fs/xattr.c static inline int write_all_xattrs(struct inode *inode, __u32 hsize, · line 445

Quoted 5 lines
fs/f2fs/xattr.c +1 -0
+
 		f2fs_wait_on_page_writeback(xpage, NODE, true);
 	} else {
 		struct dnode_of_data dn;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

#2 lore raw
Quoted 15 lines · Chao Yu
Quoted 14 lines · Kinglong Mee

If hsize is less than or equal to inlien_size, and i_xattr_nid is valid, the new_nid is not allocated (no alloc_nid is called).

       if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
                if (!alloc_nid(sbi, &new_nid))
                        return -ENOSPC;

Although it's harmless calling alloc_nid_failed, it's better drop them.

---
 fs/f2fs/xattr.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
Quoted 11 lines

fs/f2fs/xattr.c static inline int write_all_xattrs(struct inode *inode, __u32 hsize, · line 431

Quoted 9 lines
fs/f2fs/xattr.c +0 -1
index 7298a44..fd9dc99 100644
@@ -428,19 +428,18 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
 		/* no need to use xattr node block */
 		if (hsize <= inline_size) {
 			err = truncate_xattr_node(inode, ipage);
-			alloc_nid_failed(sbi, new_nid);

Should keep this since new_nid was assigned above?

alloc_nid is called when,

403 if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
404 if (!alloc_nid(sbi, &new_nid))
405 return -ENOSPC;

if (hsize <= inline_size), alloc_nid isn't called.

thanks,
Kinglong Mee

Quoted 19 lines
Quoted 6 lines
fs/f2fs/xattr.c +1 -0
+			f2fs_bug_on(sbi, new_nid);
 			return err;
 		}
 	}
 

fs/f2fs/xattr.c static inline int write_all_xattrs(struct inode *inode, __u32 hsize, · line 443

Quoted 10 lines
fs/f2fs/xattr.c +2 -4
 	/* write to xattr node block */
 	if (F2FS_I(inode)->i_xattr_nid) {
+		f2fs_bug_on(sbi, new_nid);
 		xpage = get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
-		if (IS_ERR(xpage)) {
-			alloc_nid_failed(sbi, new_nid);
+		if (IS_ERR(xpage))
 			return PTR_ERR(xpage);
-		}
-		f2fs_bug_on(sbi, new_nid);

Cleanup here looks good to me.

Quoted 9 lines

Thanks,

Quoted 5 lines
fs/f2fs/xattr.c +1 -0
+
 		f2fs_wait_on_page_writeback(xpage, NODE, true);
 	} else {
 		struct dnode_of_data dn;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

#3 lore raw
Quoted 28 lines · Kinglong Mee
Quoted 15 lines · Chao Yu
Quoted 14 lines · Kinglong Mee

If hsize is less than or equal to inlien_size, and i_xattr_nid is valid, the new_nid is not allocated (no alloc_nid is called).

       if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
                if (!alloc_nid(sbi, &new_nid))
                        return -ENOSPC;

Although it's harmless calling alloc_nid_failed, it's better drop them.

---
 fs/f2fs/xattr.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
Quoted 11 lines

fs/f2fs/xattr.c static inline int write_all_xattrs(struct inode *inode, __u32 hsize, · line 431

Quoted 9 lines
fs/f2fs/xattr.c +0 -1
index 7298a44..fd9dc99 100644
@@ -428,19 +428,18 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
 		/* no need to use xattr node block */
 		if (hsize <= inline_size) {
 			err = truncate_xattr_node(inode, ipage);
-			alloc_nid_failed(sbi, new_nid);

Should keep this since new_nid was assigned above?

Quoted 8 lines

alloc_nid is called when,

403 if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
404 if (!alloc_nid(sbi, &new_nid))
405 return -ENOSPC;

if (hsize <= inline_size), alloc_nid isn't called.

You're right, I can confirm that. :)

Thanks,

Quoted 32 lines

thanks,
Kinglong Mee

Quoted 19 lines
Quoted 6 lines
fs/f2fs/xattr.c +1 -0
+			f2fs_bug_on(sbi, new_nid);
 			return err;
 		}
 	}
 

fs/f2fs/xattr.c static inline int write_all_xattrs(struct inode *inode, __u32 hsize, · line 443

Quoted 10 lines
fs/f2fs/xattr.c +2 -4
 	/* write to xattr node block */
 	if (F2FS_I(inode)->i_xattr_nid) {
+		f2fs_bug_on(sbi, new_nid);
 		xpage = get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
-		if (IS_ERR(xpage)) {
-			alloc_nid_failed(sbi, new_nid);
+		if (IS_ERR(xpage))
 			return PTR_ERR(xpage);
-		}
-		f2fs_bug_on(sbi, new_nid);

Cleanup here looks good to me.

Quoted 9 lines

Thanks,

Quoted 5 lines
fs/f2fs/xattr.c +1 -0
+
 		f2fs_wait_on_page_writeback(xpage, NODE, true);
 	} else {
 		struct dnode_of_data dn;
Quoted 2 lines

.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot