Skip to contentSkip to conversation

f2fs: fix wrong return value of f2fs_bmap_compress()

PATCH New Chao Yu 2 participants 5 messages Jun 28, 2020 – Jul 3, 2020

Subsystems (2)
lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/3 f2fs: fix wrong return value of f2fs_bmap_compress()

If compression is disable, we should return zero rather than -EOPNOTSUPP to indicate f2fs_bmap() is not supported.

---
 fs/f2fs/data.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/f2fs/data.c +1 -2
index dfd322515357..91dc7b598961 100644
@@ -3703,10 +3703,9 @@ static sector_t f2fs_bmap_compress(struct inode *inode, sector_t block)
 	}
 
 	f2fs_put_dnode(&dn);
-
 	return blknr;
 #else
-	return -EOPNOTSUPP;
+	return 0;
 #endif
 }
 
Signature · 1 line
2.26.2
author
#1 lore raw

PATCH 2/3 f2fs: support to trace f2fs_bmap()

to show f2fs_bmap()'s result as below:

f2fs_bmap: dev = (251,0), ino = 7, lblock:0, pblock:396800

---
 fs/f2fs/data.c              | 14 +++++++++++---
 include/trace/events/f2fs.h | 27 +++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 3 deletions(-)
fs/f2fs/data.c +11 -3
index 91dc7b598961..c07a50e4d967 100644
@@ -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
include/trace/events/f2fs.h +27 -0
index 8639ab962a71..3d844c51d283 100644
@@ -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 */
Signature · 1 line
2.26.2
#2 lore raw

Re: [PATCH 2/3] f2fs: support to trace f2fs_bmap()

I love your patch! Perhaps something to improve:

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

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/kbuild-all(a)lists.01.org

#3 lore raw

Re: [PATCH 2/3] f2fs: support to trace f2fs_bmap()

In reply to Chao Yu
I love your patch! Perhaps something to improve:

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]
[cannot apply to next-20200702]
[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-randconfig-r021-20200702 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project ca464639a1c9dd3944eb055ffd2796e8c2e7639f)

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
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from include/linux/backing-dev.h:15:
In file included from include/linux/blkdev.h:28:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:490:45: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]

           val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
           ___constant_swab32(x) :                 \
                              ^
   include/uapi/linux/swab.h:20:12: note: expanded from macro '___constant_swab32'
           (((__u32)(x) & (__u32)0x0000ff00UL) <<  8) |            \
                     ^
   In file included from fs/f2fs/super.c:13:
   In file included from include/linux/backing-dev.h:15:
   In file included from include/linux/blkdev.h:28:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:72:
   include/asm-generic/io.h:490:45: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
           ___constant_swab32(x) :                 \
                              ^
   include/uapi/linux/swab.h:21:12: note: expanded from macro '___constant_swab32'
           (((__u32)(x) & (__u32)0x00ff0000UL) >>  8) |            \
                     ^
   In file included from fs/f2fs/super.c:13:
   In file included from include/linux/backing-dev.h:15:
   In file included from include/linux/blkdev.h:28:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:72:
   include/asm-generic/io.h:490:45: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
           ___constant_swab32(x) :                 \
                              ^
   include/uapi/linux/swab.h:22:12: note: expanded from macro '___constant_swab32'
           (((__u32)(x) & (__u32)0xff000000UL) >> 24)))
                     ^
   In file included from fs/f2fs/super.c:13:
   In file included from include/linux/backing-dev.h:15:
   In file included from include/linux/blkdev.h:28:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:72:
   include/asm-generic/io.h:490:45: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:120:12: note: expanded from macro '__swab32'
           __fswab32(x))
                     ^
   In file included from fs/f2fs/super.c:13:
   In file included from include/linux/backing-dev.h:15:
   In file included from include/linux/blkdev.h:28:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:72:
   include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:511:46: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew(cpu_to_le16(value), PCI_IOBASE + addr);
                                            ~~~~~~~~~~ ^
   include/asm-generic/io.h:521:46: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel(cpu_to_le32(value), PCI_IOBASE + addr);
                                            ~~~~~~~~~~ ^
   include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   In file included from fs/f2fs/super.c:37:
   In file included from include/trace/events/f2fs.h:1924:
   In file included from include/trace/define_trace.h:102:
   In file included from include/trace/trace_events.h:402:
>> include/trace/events/f2fs.h:1916:3: warning: format specifies type 'unsigned long' but the argument has type 'ino_t' (aka 'unsigned int') [-Wformat]
                   __entry->ino,
                   ^~~~~~~~~~~~~
   include/trace/trace_events.h:264:17: note: expanded from macro '__entry'
   #define __entry field
                   ^
   include/trace/trace_events.h:267:43: note: expanded from macro 'TP_printk'
   #define TP_printk(fmt, args...) fmt "\n", args
                                   ~~~       ^
   include/trace/trace_events.h:80:16: note: expanded from macro 'TRACE_EVENT'
                                PARAMS(print));                   \
                                ~~~~~~~^~~~~~~
   include/linux/tracepoint.h:95:25: note: expanded from macro 'PARAMS'
   #define PARAMS(args...) args
                           ^~~~
   include/trace/trace_events.h:368:22: note: expanded from macro 'DECLARE_EVENT_CLASS'
           trace_seq_printf(s, print);                                     \
                               ^~~~~

21 warnings generated.

vim +1916 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/kbuild-all(a)lists.01.org

author
#4 lore raw

PATCH 3/3 f2fs: support to trace f2fs_fiemap()

In reply to Chao Yu

to show f2fs_fiemap()'s result as below:

f2fs_fiemap: dev = (251,0), ino = 7, lblock:0, pblock:1625292800, len:2097152, flags:0, ret:0

---
 fs/f2fs/data.c              |  6 +++++-
 fs/f2fs/inline.c            |  2 ++
 include/trace/events/f2fs.h | 38 +++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)
fs/f2fs/data.c +5 -1
index c07a50e4d967..995cf78b23c5 100644
@@ -1813,6 +1813,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
 			flags |= FIEMAP_EXTENT_LAST;
 
 		err = fiemap_fill_next_extent(fieinfo, 0, phys, len, flags);
+		trace_f2fs_fiemap(inode, 0, phys, len, flags, err);
 		if (err || err == 1)
 			return err;
 	}
@@ -1836,8 +1837,10 @@ static int f2fs_xattr_fiemap(struct inode *inode,
 		flags = FIEMAP_EXTENT_LAST;
 	}
 
-	if (phys)
+	if (phys) {
 		err = fiemap_fill_next_extent(fieinfo, 0, phys, len, flags);
+		trace_f2fs_fiemap(inode, 0, phys, len, flags, err);
+	}
 
 	return (err < 0 ? err : 0);
 }
@@ -1931,6 +1934,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 
 		ret = fiemap_fill_next_extent(fieinfo, logical,
 				phys, size, flags);
+		trace_f2fs_fiemap(inode, logical, phys, size, flags, ret);
 		if (ret)
 			goto out;
 		size = 0;
fs/f2fs/inline.c +2 -0
index dbade310dc79..def4b8481883 100644
@@ -12,6 +12,7 @@
 
 #include "f2fs.h"
 #include "node.h"
+#include <trace/events/f2fs.h>
 
 bool f2fs_may_inline_data(struct inode *inode)
 {
@@ -776,6 +777,7 @@ int f2fs_inline_data_fiemap(struct inode *inode,
 	byteaddr += (char *)inline_data_addr(inode, ipage) -
 					(char *)F2FS_INODE(ipage);
 	err = fiemap_fill_next_extent(fieinfo, start, byteaddr, ilen, flags);
+	trace_f2fs_fiemap(inode, start, byteaddr, ilen, flags, err);
 out:
 	f2fs_put_page(ipage, 1);
 	return err;
include/trace/events/f2fs.h +38 -0
index 3d844c51d283..67202963ef82 100644
@@ -1918,6 +1918,44 @@ TRACE_EVENT(f2fs_bmap,
 		(unsigned long long)__entry->pblock)
 );
 
+TRACE_EVENT(f2fs_fiemap,
+
+	TP_PROTO(struct inode *inode, sector_t lblock, sector_t pblock,
+		unsigned long long len, unsigned int flags, int ret),
+
+	TP_ARGS(inode, lblock, pblock, len, flags, ret),
+
+	TP_STRUCT__entry(
+		__field(dev_t, dev)
+		__field(ino_t, ino)
+		__field(sector_t, lblock)
+		__field(sector_t, pblock)
+		__field(unsigned long long, len)
+		__field(unsigned int, flags)
+		__field(int, ret)
+	),
+
+	TP_fast_assign(
+		__entry->dev		= inode->i_sb->s_dev;
+		__entry->ino		= inode->i_ino;
+		__entry->lblock		= lblock;
+		__entry->pblock		= pblock;
+		__entry->len		= len;
+		__entry->flags		= flags;
+		__entry->ret		= ret;
+	),
+
+	TP_printk("dev = (%d,%d), ino = %lu, lblock:%lld, pblock:%lld, "
+		"len:%llu, flags:%u, ret:%d",
+		show_dev(__entry->dev),
+		__entry->ino,
+		(unsigned long long)__entry->lblock,
+		(unsigned long long)__entry->pblock,
+		__entry->len,
+		__entry->flags,
+		__entry->ret)
+);
+
 #endif /* _TRACE_F2FS_H */
 
  /* This part must be outside protection */
Signature · 1 line
2.26.2