Skip to contentSkip to conversation

Btrfs: fix missing log when BTRFS_INODE_NEEDS_FULL_SYNC is set

PATCH In review Miao Xie 2 participants 3 messages Nov 1, 2012 – Nov 2, 2012 Btrfs file system

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

PATCH 5/5 Btrfs: fix missing log when BTRFS_INODE_NEEDS_FULL_SYNC is set

If we set BTRFS_INODE_NEEDS_FULL_SYNC, we should log all the extent, but now we forget to take it into account, and set a wrong max key, if so, we will skip the file extent metadata when doing logging. Fix it.

---
 fs/btrfs/tree-log.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/btrfs/tree-log.c +4 -1
index f7e9387..c495b47 100644
@@ -3394,7 +3394,10 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
 
 
 	/* today the code can only do partial logging of directories */
-	if (inode_only == LOG_INODE_EXISTS || S_ISDIR(inode->i_mode))
+	if (S_ISDIR(inode->i_mode) ||
+	    (!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
+		       &BTRFS_I(inode)->runtime_flags) &&
+	     inode_only == LOG_INODE_EXISTS))
 		max_key.type = BTRFS_XATTR_ITEM_KEY;
 	else
 		max_key.type = (u8)-1;
Signature · 1 line
1.7.6.5
#1 lore raw
Quoted 4 lines · Miao Xie

If we set BTRFS_INODE_NEEDS_FULL_SYNC, we should log all the extent, but now we forget to take it into account, and set a wrong max key, if so, we will skip the file extent metadata when doing logging. Fix it.

But it's along with LOG_INODE_EXISTS, which is set by rename and link and means we need to log just enough to rebuild the inode during log replay.

On the other side, if we do log all the extents because of having set BTRFS_INODE_NEEDS_FULL_SYNC, we don't know if we actually get what we want because rename and link do not wait for dirty pages as fsync does.

thanks,
liubo

Quoted 27 lines
---
 fs/btrfs/tree-log.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/btrfs/tree-log.c +4 -1
index f7e9387..c495b47 100644
@@ -3394,7 +3394,10 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
 
 
 	/* today the code can only do partial logging of directories */
-	if (inode_only == LOG_INODE_EXISTS || S_ISDIR(inode->i_mode))
+	if (S_ISDIR(inode->i_mode) ||
+	    (!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
+		       &BTRFS_I(inode)->runtime_flags) &&
+	     inode_only == LOG_INODE_EXISTS))
 		max_key.type = BTRFS_XATTR_ITEM_KEY;
 	else
 		max_key.type = (u8)-1;
Signature · 5 lines
1.7.6.5
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#2 lore raw
Quoted 6 lines · Liu Bo
Quoted 4 lines · Miao Xie

If we set BTRFS_INODE_NEEDS_FULL_SYNC, we should log all the extent, but now we forget to take it into account, and set a wrong max key, if so, we will skip the file extent metadata when doing logging. Fix it.

Quoted 6 lines

But it's along with LOG_INODE_EXISTS, which is set by rename and link and means we need to log just enough to rebuild the inode during log replay.

On the other side, if we do log all the extents because of having set BTRFS_INODE_NEEDS_FULL_SYNC, we don't know if we actually get what we want because rename and link do not wait for dirty pages as fsync does.

Full sync is the safest way to log. I think we should not ignore it since it is set.

Thanks
Miao

Quoted 36 lines

thanks,
liubo

Quoted 27 lines
---
 fs/btrfs/tree-log.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/btrfs/tree-log.c +4 -1
index f7e9387..c495b47 100644
@@ -3394,7 +3394,10 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
 
 
 	/* today the code can only do partial logging of directories */
-	if (inode_only == LOG_INODE_EXISTS || S_ISDIR(inode->i_mode))
+	if (S_ISDIR(inode->i_mode) ||
+	    (!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
+		       &BTRFS_I(inode)->runtime_flags) &&
+	     inode_only == LOG_INODE_EXISTS))
 		max_key.type = BTRFS_XATTR_ITEM_KEY;
 	else
 		max_key.type = (u8)-1;
Signature · 5 lines
1.7.6.5
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html