Btrfs: remove warning check in io_ctl_map_page
A message that is not in the archive (sent off-list or not yet received): 1354255348-5011-1-git-send-email-y
PATCH 1/1 Btrfs: remove warning check in io_ctl_map_page
From: Wang Sheng-Hui <[email protected]>
io_ctl_map_page is called by many functions in free-space-cache. In some scenarios, the ->cur is not null, e.g. io_ctl_add_entry. Remove the check here.
--- fs/btrfs/free-space-cache.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
fs/btrfs/free-space-cache.c +0 -1
@@ -307,7 +307,6 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl)static void io_ctl_map_page (struct io_ctl *io_ctl,int clear) { -WARN_ON (io_ctl->cur);BUG_ON (io_ctl->index >= io_ctl->num_pages); io_ctl->page = io_ctl->pages[io_ctl->index++]; io_ctl->cur =kmap (io_ctl->page);
Signature · 1 line
1.6.0.2
Quoted 5 lines · On Fri, Nov 30, 2012 at 02:02:26PM +0800, [email protected] wrote:
From: Wang Sheng-Hui <[email protected]>
io_ctl_map_pageis called by many functions in free-space-cache. In some scenarios, the ->cur is not null, e.g.io_ctl_add_entry. Remove the check here.
Hi Wang,
Seems to be impossible according to the code, even in io_ctl_add_entry().
So have you seen such a warning in your flight running? If you do, maybe you can post it here and we can figure out the whys.
thanks,
liubo
Quoted 25 lines
Signed-off-by Wang Sheng-Hui <[email protected]>--- fs/btrfs/free-space-cache.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)fs/btrfs/free-space-cache.c +0
-1@@ -307,7 +307,6 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl)static void io_ctl_map_page (struct io_ctl *io_ctl,int clear) { -WARN_ON (io_ctl->cur);BUG_ON (io_ctl->index >= io_ctl->num_pages); io_ctl->page = io_ctl->pages[io_ctl->index++]; io_ctl->cur =kmap (io_ctl->page);Signature · 6 lines
1.6.0.2 -- 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
Quoted 7 lines · Liu Bo
Quoted 5 lines · On Fri, Nov 30, 2012 at 02:02:26PM +0800, [email protected] wrote:
From: Wang Sheng-Hui <[email protected]>
io_ctl_map_pageis called by many functions in free-space-cache. In some scenarios, the ->cur is not null, e.g.io_ctl_add_entry. Remove the check here.
Quoted 7 lines
Hi Wang,
Seems to be impossible according to the code, even in
io_ctl_add_entry().So have you seen such a warning in your flight running? If you do, maybe you can post it here and we can figure out the whys.
Hi Liu Bo,
I just walked through the code. reread io_ctl_add_entry, and just noticed that io_ctl_set_crc is called before io_ctl_map_page, which can guarantee the ->cur is set to null before map.
Thanks for helping me understand the code.
Regards,
Sheng-Hui
Quoted 28 lines
thanks,
liuboQuoted 25 lines
Signed-off-by Wang Sheng-Hui <[email protected]>--- fs/btrfs/free-space-cache.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)fs/btrfs/free-space-cache.c +0
-1@@ -307,7 +307,6 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl)static void io_ctl_map_page (struct io_ctl *io_ctl,int clear) { -WARN_ON (io_ctl->cur);BUG_ON (io_ctl->index >= io_ctl->num_pages); io_ctl->page = io_ctl->pages[io_ctl->index++]; io_ctl->cur =kmap (io_ctl->page);Signature · 6 lines
1.6.0.2 -- 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
PATCH 1/1 Btrfs: check crc area early in io_ctl_init
In reply to a message not in the archiveFrom: Wang Sheng-Hui <[email protected]>
When use crc area, we should check if it can host the desired num of crcs. Add the check in init stage.
And the check should be more strict: the first page has sizeof(u64)*2 cannot used for crc.
--- fs/btrfs/free-space-cache.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
fs/btrfs/free-space-cache.c +9 -2
@@ -286,8 +286,14 @@ static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode,if (!io_ctl->pages)return -ENOMEM ; io_ctl->root = root; -if (btrfs_ino (inode) !=BTRFS_FREE_INO_OBJECTID ) +if (btrfs_ino (inode) !=BTRFS_FREE_INO_OBJECTID ) { io_ctl->check_crcs =1 ; +if ((io_ctl.num_pages *sizeof (u32)) > + (PAGE_CACHE_SIZE -sizeof (u64) *2 )) { +WARN_ON (1 ); +return -1 ; + } + }return 0 ; }
@@ -917,7 +923,8 @@ int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,/* Make sure we can fit our crcs into the first page */ if (io_ctl.check_crcs && - (io_ctl.num_pages *sizeof (u32)) >=PAGE_CACHE_SIZE ) { + (io_ctl.num_pages *sizeof (u32)) > + (PAGE_CACHE_SIZE -sizeof (u64) *2 )) {WARN_ON (1 ); goto out_nospc; }
Signature · 1 line
1.6.0.2
PATCH 1/1 Btrfs: cleanup: assign path->nodes[0]to leaf after ret check in __btrfs_write_out_cache
In reply to a message not in the archiveFrom: Wang Sheng-Hui <[email protected]>
If the ret check fails, the assignment is useless. Move the assignment after the check.
--- fs/btrfs/free-space-cache.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/btrfs/free-space-cache.c +1 -1
@@ -1033,7 +1033,6 @@ int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, GFP_NOFS); goto out; } - leaf = path->nodes[0 ];if (ret >0 ) {struct btrfs_key found_key;BUG_ON (!path->slots[0 ]);
@@ -1049,6 +1048,7 @@ int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, goto out; } } + leaf = path->nodes[0 ];BTRFS_I (inode)->generation = trans->transid; header = btrfs_item_ptr(leaf, path->slots[0],
Signature · 1 line
1.6.0.2