to show f2fs_bmap()'s result as below:
f2fs_bmap: dev = (251,0), ino = 7, lblock:0, pblock:396800
Signed-off-by: Chao Yu <[email protected]>
---
fs/f2fs/data.c | 14 +++++++++++---
include/trace/events/f2fs.h | 27 +++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 91dc7b598961..c07a50e4d967 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3713,18 +3713,26 @@ static sector_t f2fs_bmap_compress(struct inode *inode, sector_t block)
static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
{
struct inode *inode = mapping->host;
+ struct buffer_head tmp = {
+ .b_size = i_blocksize(inode),
+ };
+ sector_t blknr = 0;
if (f2fs_has_inline_data(inode))
- return 0;
+ goto out;
/* make sure allocating whole blocks */
if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
filemap_write_and_wait(mapping);
if (f2fs_compressed_file(inode))
- return f2fs_bmap_compress(inode, block);
+ blknr = f2fs_bmap_compress(inode, block);
- return generic_block_bmap(mapping, block, get_data_block_bmap);
+ if (!get_data_block_bmap(inode, block, &tmp, 0))
+ blknr = tmp.b_blocknr;
+out:
+ trace_f2fs_bmap(inode, block, blknr);
+ return blknr;
}
#ifdef CONFIG_MIGRATION
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 8639ab962a71..3d844c51d283 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -1891,6 +1891,33 @@ TRACE_EVENT(f2fs_iostat,
__entry->fs_cdrio, __entry->fs_nrio, __entry->fs_mrio)
);
+TRACE_EVENT(f2fs_bmap,
+
+ TP_PROTO(struct inode *inode, sector_t lblock, sector_t pblock),
+
+ TP_ARGS(inode, lblock, pblock),
+
+ TP_STRUCT__entry(
+ __field(dev_t, dev)
+ __field(ino_t, ino)
+ __field(sector_t, lblock)
+ __field(sector_t, pblock)
+ ),
+
+ TP_fast_assign(
+ __entry->dev = inode->i_sb->s_dev;
+ __entry->ino = inode->i_ino;
+ __entry->lblock = lblock;
+ __entry->pblock = pblock;
+ ),
+
+ TP_printk("dev = (%d,%d), ino = %lu, lblock:%lld, pblock:%lld",
+ show_dev(__entry->dev),
+ __entry->ino,
+ (unsigned long long)__entry->lblock,
+ (unsigned long long)__entry->pblock)
+);
+
#endif /* _TRACE_F2FS_H */
/* This part must be outside protection */
--
2.26.2
Hi Chao,
I love your patch! Perhaps something to improve:
[auto build test WARNING on f2fs/dev-test]
[also build test WARNING on v5.8-rc3 next-20200629]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Chao-Yu/f2fs-fix-wrong-return-value-of-f2fs_bmap_compress/20200628-203231
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: s390-allyesconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=s390
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All warnings (new ones prefixed by >>):
In file included from include/trace/define_trace.h:102,
from include/trace/events/f2fs.h:1924,
from fs/f2fs/super.c:37:
include/trace/events/f2fs.h: In function 'trace_raw_output_f2fs_bmap':
>> include/trace/events/f2fs.h:1914:12: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'ino_t' {aka 'unsigned int'} [-Wformat=]
1914 | TP_printk("dev = (%d,%d), ino = %lu, lblock:%lld, pblock:%lld",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/trace/trace_events.h:368:22: note: in definition of macro 'DECLARE_EVENT_CLASS'
368 | trace_seq_printf(s, print); \
| ^~~~~
include/trace/trace_events.h:80:9: note: in expansion of macro 'PARAMS'
80 | PARAMS(print)); \
| ^~~~~~
include/trace/events/f2fs.h:1894:1: note: in expansion of macro 'TRACE_EVENT'
1894 | TRACE_EVENT(f2fs_bmap,
| ^~~~~~~~~~~
>> include/trace/events/f2fs.h:1914:2: note: in expansion of macro 'TP_printk'
1914 | TP_printk("dev = (%d,%d), ino = %lu, lblock:%lld, pblock:%lld",
| ^~~~~~~~~
In file included from include/trace/trace_events.h:402,
from include/trace/define_trace.h:102,
from include/trace/events/f2fs.h:1924,
from fs/f2fs/super.c:37:
include/trace/events/f2fs.h:1914:36: note: format string is defined here
1914 | TP_printk("dev = (%d,%d), ino = %lu, lblock:%lld, pblock:%lld",
| ~~^
| |
| long unsigned int
| %u
vim +1914 include/trace/events/f2fs.h
1895
1896 TP_PROTO(struct inode *inode, sector_t lblock, sector_t pblock),
1897
1898 TP_ARGS(inode, lblock, pblock),
1899
1900 TP_STRUCT__entry(
1901 __field(dev_t, dev)
1902 __field(ino_t, ino)
1903 __field(sector_t, lblock)
1904 __field(sector_t, pblock)
1905 ),
1906
1907 TP_fast_assign(
1908 __entry->dev = inode->i_sb->s_dev;
1909 __entry->ino = inode->i_ino;
1910 __entry->lblock = lblock;
1911 __entry->pblock = pblock;
1912 ),
1913
> 1914 TP_printk("dev = (%d,%d), ino = %lu, lblock:%lld, pblock:%lld",
1915 show_dev(__entry->dev),
1916 __entry->ino,
1917 (unsigned long long)__entry->lblock,
1918 (unsigned long long)__entry->pblock)
1919 );
1920
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]