tree:
https://github.com/goldwynr/linux btrfs-inode-lock
head: 5fa699884bb1683e98e07bc73d2dd9c0f219742c
commit: 2dec6d472f199ebac0023fd8f9275aaba80bbe19 [10/15] btrfs: Push inode locking and
unlocking into buffered/direct write
config: x86_64-randconfig-a002-20200921 (attached as .config)
compiler: clang version 12.0.0 (
https://github.com/llvm/llvm-project
4e8c028158b56d9c2142a62464e8e0686bde3584)
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 x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
git checkout 2dec6d472f199ebac0023fd8f9275aaba80bbe19
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
> fs/btrfs/file.c:2147:37: warning: variable 'err' is
uninitialized when used here [-Wuninitialized]
return num_written ?
num_written : err;
^~~
fs/btrfs/file.c:2075:13: note: initialize the variable 'err' to silence this
warning
ssize_t err;
^
= 0
1 warning generated.
#
https://github.com/goldwynr/linux/commit/2dec6d472f199ebac0023fd8f9275aab...
git remote add goldwynr
https://github.com/goldwynr/linux
git fetch --no-tags goldwynr btrfs-inode-lock
git checkout 2dec6d472f199ebac0023fd8f9275aaba80bbe19
vim +/err +2147 fs/btrfs/file.c
d0215f3e5ebb58 Josef Bacik 2011-01-25 2065
b30ac0fc410970 Al Viro 2014-04-03 2066 static ssize_t
btrfs_file_write_iter(struct kiocb *iocb,
b30ac0fc410970 Al Viro 2014-04-03 2067 struct iov_iter *from)
d0215f3e5ebb58 Josef Bacik 2011-01-25 2068 {
d0215f3e5ebb58 Josef Bacik 2011-01-25 2069 struct file *file = iocb->ki_filp;
496ad9aa8ef448 Al Viro 2013-01-23 2070 struct inode *inode =
file_inode(file);
0b246afa62b0cf Jeff Mahoney 2016-06-22 2071 struct btrfs_fs_info *fs_info =
btrfs_sb(inode->i_sb);
d0215f3e5ebb58 Josef Bacik 2011-01-25 2072 struct btrfs_root *root =
BTRFS_I(inode)->root;
d0215f3e5ebb58 Josef Bacik 2011-01-25 2073 ssize_t num_written = 0;
f50cb7aff96459 Omar Sandoval 2019-08-15 2074 const bool sync = iocb->ki_flags
& IOCB_DSYNC;
3309dd04cbcd2c Al Viro 2015-04-09 2075 ssize_t err;
d0215f3e5ebb58 Josef Bacik 2011-01-25 2076
5565d30dbf72ae Goldwyn Rodrigues 2020-09-16 2077 /*
5565d30dbf72ae Goldwyn Rodrigues 2020-09-16 2078 * If BTRFS flips readonly due to some
impossible error
5565d30dbf72ae Goldwyn Rodrigues 2020-09-16 2079 * (fs_info->fs_state now has
BTRFS_SUPER_FLAG_ERROR),
5565d30dbf72ae Goldwyn Rodrigues 2020-09-16 2080 * although we have opened a file as
writable, we have
5565d30dbf72ae Goldwyn Rodrigues 2020-09-16 2081 * to stop this write operation to
ensure FS consistency.
5565d30dbf72ae Goldwyn Rodrigues 2020-09-16 2082 */
5565d30dbf72ae Goldwyn Rodrigues 2020-09-16 2083 if (test_bit(BTRFS_FS_STATE_ERROR,
&fs_info->fs_state))
5565d30dbf72ae Goldwyn Rodrigues 2020-09-16 2084 return -EROFS;
5565d30dbf72ae Goldwyn Rodrigues 2020-09-16 2085
91f9943e1c7b66 Christoph Hellwig 2017-08-29 2086 if (!(iocb->ki_flags &
IOCB_DIRECT) &&
91f9943e1c7b66 Christoph Hellwig 2017-08-29 2087 (iocb->ki_flags &
IOCB_NOWAIT))
91f9943e1c7b66 Christoph Hellwig 2017-08-29 2088 return -EOPNOTSUPP;
91f9943e1c7b66 Christoph Hellwig 2017-08-29 2089
b812ce28796f74 Josef Bacik 2012-11-16 2090 if (sync)
b812ce28796f74 Josef Bacik 2012-11-16 2091
atomic_inc(&BTRFS_I(inode)->sync_writers);
b812ce28796f74 Josef Bacik 2012-11-16 2092
2ba48ce513c4e5 Al Viro 2015-04-09 2093 if (iocb->ki_flags &
IOCB_DIRECT) {
09745ff88d9353 Josef Bacik 2020-09-03 2094 /*
09745ff88d9353 Josef Bacik 2020-09-03 2095 * 1. We must always clear IOCB_DSYNC
in order to not deadlock
09745ff88d9353 Josef Bacik 2020-09-03 2096 * in iomap, as it calls
generic_write_sync() in this case.
09745ff88d9353 Josef Bacik 2020-09-03 2097 * 2. If we are async, we can call
iomap_dio_complete() either
09745ff88d9353 Josef Bacik 2020-09-03 2098 * in
09745ff88d9353 Josef Bacik 2020-09-03 2099 *
09745ff88d9353 Josef Bacik 2020-09-03 2100 * 2.1. A worker thread from the
last bio completed. In this
09745ff88d9353 Josef Bacik 2020-09-03 2101 * case we need to mark the
btrfs_dio_data that it is
09745ff88d9353 Josef Bacik 2020-09-03 2102 * async in order to call
generic_write_sync() properly.
09745ff88d9353 Josef Bacik 2020-09-03 2103 * This is handled by setting
BTRFS_DIO_SYNC_STUB in the
09745ff88d9353 Josef Bacik 2020-09-03 2104 * current->journal_info.
09745ff88d9353 Josef Bacik 2020-09-03 2105 * 2.2 The submitter context,
because all IO completed
09745ff88d9353 Josef Bacik 2020-09-03 2106 * before we exited
iomap_dio_rw(). In this case we can
09745ff88d9353 Josef Bacik 2020-09-03 2107 * just re-set the IOCB_DSYNC
on the iocb and we'll do
09745ff88d9353 Josef Bacik 2020-09-03 2108 * the sync below. If our
->end_io() gets called and
09745ff88d9353 Josef Bacik 2020-09-03 2109 * current->journal_info
is set, then we know we're in
09745ff88d9353 Josef Bacik 2020-09-03 2110 * our current context and we
will clear
09745ff88d9353 Josef Bacik 2020-09-03 2111 * current->journal_info
to indicate that we need to
09745ff88d9353 Josef Bacik 2020-09-03 2112 * sync below.
09745ff88d9353 Josef Bacik 2020-09-03 2113 */
09745ff88d9353 Josef Bacik 2020-09-03 2114 if (sync) {
09745ff88d9353 Josef Bacik 2020-09-03 2115 ASSERT(current->journal_info ==
NULL);
09745ff88d9353 Josef Bacik 2020-09-03 2116 iocb->ki_flags &=
~IOCB_DSYNC;
09745ff88d9353 Josef Bacik 2020-09-03 2117 current->journal_info =
BTRFS_DIO_SYNC_STUB;
09745ff88d9353 Josef Bacik 2020-09-03 2118 }
27fa676c4d30aa Goldwyn Rodrigues 2020-09-16 2119 num_written =
btrfs_direct_write(iocb, from);
09745ff88d9353 Josef Bacik 2020-09-03 2120
09745ff88d9353 Josef Bacik 2020-09-03 2121 /*
09745ff88d9353 Josef Bacik 2020-09-03 2122 * As stated above, we cleared
journal_info, so we need to do
09745ff88d9353 Josef Bacik 2020-09-03 2123 * the sync ourselves.
09745ff88d9353 Josef Bacik 2020-09-03 2124 */
09745ff88d9353 Josef Bacik 2020-09-03 2125 if (sync &&
current->journal_info == NULL)
09745ff88d9353 Josef Bacik 2020-09-03 2126 iocb->ki_flags |= IOCB_DSYNC;
09745ff88d9353 Josef Bacik 2020-09-03 2127 current->journal_info = NULL;
d0215f3e5ebb58 Josef Bacik 2011-01-25 2128 } else {
e4af400a9c5081 Goldwyn Rodrigues 2018-06-17 2129 num_written =
btrfs_buffered_write(iocb, from);
d0215f3e5ebb58 Josef Bacik 2011-01-25 2130 }
d0215f3e5ebb58 Josef Bacik 2011-01-25 2131
5a3f23d515a2eb Chris Mason 2009-03-31 2132 /*
6c760c072403f4 Josef Bacik 2012-11-09 2133 * We also have to set last_sub_trans
to the current log transid,
6c760c072403f4 Josef Bacik 2012-11-09 2134 * otherwise subsequent syncs to a
file that's been synced in this
bb7ab3b92e46da Adam Buchbinder 2016-03-04 2135 * transaction will appear to have
already occurred.
5a3f23d515a2eb Chris Mason 2009-03-31 2136 */
2f2ff0ee5e4303 Filipe Manana 2015-03-20 2137
spin_lock(&BTRFS_I(inode)->lock);
6c760c072403f4 Josef Bacik 2012-11-09 2138 BTRFS_I(inode)->last_sub_trans =
root->log_transid;
2f2ff0ee5e4303 Filipe Manana 2015-03-20 2139
spin_unlock(&BTRFS_I(inode)->lock);
e259221763a404 Christoph Hellwig 2016-04-07 2140 if (num_written > 0)
e259221763a404 Christoph Hellwig 2016-04-07 2141 num_written =
generic_write_sync(iocb, num_written);
0a3404dcff29a7 Miao Xie 2013-01-28 2142
b812ce28796f74 Josef Bacik 2012-11-16 2143 if (sync)
b812ce28796f74 Josef Bacik 2012-11-16 2144
atomic_dec(&BTRFS_I(inode)->sync_writers);
26ec73db06b185 Goldwyn Rodrigues 2020-09-16 2145
39279cc3d2704c Chris Mason 2007-06-12 2146 current->backing_dev_info = NULL;
39279cc3d2704c Chris Mason 2007-06-12 @2147 return num_written ? num_written :
err;
39279cc3d2704c Chris Mason 2007-06-12 2148 }
39279cc3d2704c Chris Mason 2007-06-12 2149
:::::: The code at line 2147 was first introduced by commit
:::::: 39279cc3d2704cfbf9c35dcb5bdd392159ae4625 Btrfs: split up super.c
:::::: TO: Chris Mason <chris.mason(a)oracle.com>
:::::: CC: David Woodhouse <dwmw2(a)hera.kernel.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org