Message ID | 1373590852-29544-1-git-send-email-wenqing.lz@taobao.com |
---|---|
State | Superseded, archived |
Headers | show |
On Fri, Jul 12, 2013 at 09:00:52AM +0800, Zheng Liu wrote: > From: Zheng Liu <wenqing.lz@taobao.com> > > In this commit (921f266b) a sanity check is added in map_blocks to make > sure 'retval == map->m_len'. But we'd better enable this check all the > time because it can help us to dig some bugs that is hard to be hitted. > > Cc: "Theodore Ts'o" <tytso@mit.edu> > Signed-off-by: Zheng Liu <wenqing.lz@taobao.com> Any comment? Thanks - Zheng > --- > changelog: > v2 <- v1: > * print more details to help us to dig some bugs that is hard to be hitted > > v1: http://patchwork.ozlabs.org/patch/230406/ > > Hi Ted, > > This patch sleeps on my own tree for a very long time so that I almost forgot > it. Sorry about that. > > - Zheng > > fs/ext4/inode.c | 39 ++++++++++++++++++--------------------- > 1 file changed, 18 insertions(+), 21 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 19a1643..95bad70 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -556,14 +556,13 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, > int ret; > unsigned long long status; > > -#ifdef ES_AGGRESSIVE_TEST > - if (retval != map->m_len) { > - printk("ES len assertation failed for inode: %lu " > - "retval %d != map->m_len %d " > - "in %s (lookup)\n", inode->i_ino, retval, > - map->m_len, __func__); > + if (unlikely(retval != map->m_len)) { > + ext4_warning(inode->i_sb, > + "ES len assertation failed for inode: " > + "%lu retval %d != map->m_len %d\n", > + inode->i_ino, retval, map->m_len); > + WARN_ON(1); > } > -#endif > > status = map->m_flags & EXT4_MAP_UNWRITTEN ? > EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; > @@ -657,14 +656,13 @@ found: > int ret; > unsigned long long status; > > -#ifdef ES_AGGRESSIVE_TEST > - if (retval != map->m_len) { > - printk("ES len assertation failed for inode: %lu " > - "retval %d != map->m_len %d " > - "in %s (allocation)\n", inode->i_ino, retval, > - map->m_len, __func__); > + if (unlikely(retval != map->m_len)) { > + ext4_warning(inode->i_sb, > + "ES len assertation failed for inode: " > + "%lu retval %d != map->m_len %d\n", > + inode->i_ino, retval, map->m_len); > + WARN_ON(1); > } > -#endif > > /* > * If the extent has been zeroed out, we don't need to update > @@ -1640,14 +1638,13 @@ add_delayed: > int ret; > unsigned long long status; > > -#ifdef ES_AGGRESSIVE_TEST > - if (retval != map->m_len) { > - printk("ES len assertation failed for inode: %lu " > - "retval %d != map->m_len %d " > - "in %s (lookup)\n", inode->i_ino, retval, > - map->m_len, __func__); > + if (unlikely(retval != map->m_len)) { > + ext4_warning(inode->i_sb, > + "ES len assertation failed for inode: " > + "%lu retval %d != map->m_len %d\n", > + inode->i_ino, retval, map->m_len); > + WARN_ON(1); > } > -#endif > > status = map->m_flags & EXT4_MAP_UNWRITTEN ? > EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; > -- > 1.7.9.7 > -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 19a1643..95bad70 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -556,14 +556,13 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, int ret; unsigned long long status; -#ifdef ES_AGGRESSIVE_TEST - if (retval != map->m_len) { - printk("ES len assertation failed for inode: %lu " - "retval %d != map->m_len %d " - "in %s (lookup)\n", inode->i_ino, retval, - map->m_len, __func__); + if (unlikely(retval != map->m_len)) { + ext4_warning(inode->i_sb, + "ES len assertation failed for inode: " + "%lu retval %d != map->m_len %d\n", + inode->i_ino, retval, map->m_len); + WARN_ON(1); } -#endif status = map->m_flags & EXT4_MAP_UNWRITTEN ? EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; @@ -657,14 +656,13 @@ found: int ret; unsigned long long status; -#ifdef ES_AGGRESSIVE_TEST - if (retval != map->m_len) { - printk("ES len assertation failed for inode: %lu " - "retval %d != map->m_len %d " - "in %s (allocation)\n", inode->i_ino, retval, - map->m_len, __func__); + if (unlikely(retval != map->m_len)) { + ext4_warning(inode->i_sb, + "ES len assertation failed for inode: " + "%lu retval %d != map->m_len %d\n", + inode->i_ino, retval, map->m_len); + WARN_ON(1); } -#endif /* * If the extent has been zeroed out, we don't need to update @@ -1640,14 +1638,13 @@ add_delayed: int ret; unsigned long long status; -#ifdef ES_AGGRESSIVE_TEST - if (retval != map->m_len) { - printk("ES len assertation failed for inode: %lu " - "retval %d != map->m_len %d " - "in %s (lookup)\n", inode->i_ino, retval, - map->m_len, __func__); + if (unlikely(retval != map->m_len)) { + ext4_warning(inode->i_sb, + "ES len assertation failed for inode: " + "%lu retval %d != map->m_len %d\n", + inode->i_ino, retval, map->m_len); + WARN_ON(1); } -#endif status = map->m_flags & EXT4_MAP_UNWRITTEN ? EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;