Re: [PATCH] nvmet: Reset ns->file when open fails

From: kernel test robot
Date: Wed May 12 2021 - 11:27:42 EST


Hi Daniel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on hch-configfs/for-next linus/master v5.13-rc1 next-20210512]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Daniel-Wagner/nvmet-Reset-ns-file-when-open-fails/20210512-181435
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git dd860052c99b1e088352bdd4fb7aef46f8d2ef47
config: nios2-randconfig-p002-20210512 (attached as .config)
compiler: nios2-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
# https://github.com/0day-ci/linux/commit/406c65a33980a0f58f21c897d9283d9fff9a4eb5
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Daniel-Wagner/nvmet-Reset-ns-file-when-open-fails/20210512-181435
git checkout 406c65a33980a0f58f21c897d9283d9fff9a4eb5
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=nios2

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/nvme/target/io-cmd-file.c: In function 'nvmet_file_ns_enable':
>> drivers/nvme/target/io-cmd-file.c:54:7: warning: assignment to 'int' from 'struct file *' makes integer from pointer without a cast [-Wint-conversion]
54 | ret = ns->file;
| ^
>> drivers/nvme/target/io-cmd-file.c:56:18: warning: passing argument 1 of 'PTR_ERR' makes pointer from integer without a cast [-Wint-conversion]
56 | return PTR_ERR(ret);
| ^~~
| |
| int
In file included from include/linux/kernfs.h:10,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/energy_model.h:7,
from include/linux/device.h:16,
from include/linux/dma-mapping.h:7,
from drivers/nvme/target/nvmet.h:9,
from drivers/nvme/target/io-cmd-file.c:11:
include/linux/err.h:29:61: note: expected 'const void *' but argument is of type 'int'
29 | static inline long __must_check PTR_ERR(__force const void *ptr)
| ~~~~~~~~~~~~^~~


vim +54 drivers/nvme/target/io-cmd-file.c

41
42 int nvmet_file_ns_enable(struct nvmet_ns *ns)
43 {
44 int flags = O_RDWR | O_LARGEFILE;
45 int ret;
46
47 if (!ns->buffered_io)
48 flags |= O_DIRECT;
49
50 ns->file = filp_open(ns->device_path, flags, 0);
51 if (IS_ERR(ns->file)) {
52 pr_err("failed to open file %s: (%ld)\n",
53 ns->device_path, PTR_ERR(ns->file));
> 54 ret = ns->file;
55 ns->file = NULL;
> 56 return PTR_ERR(ret);
57 }
58
59 ret = nvmet_file_ns_revalidate(ns);
60 if (ret)
61 goto err;
62
63 /*
64 * i_blkbits can be greater than the universally accepted upper bound,
65 * so make sure we export a sane namespace lba_shift.
66 */
67 ns->blksize_shift = min_t(u8,
68 file_inode(ns->file)->i_blkbits, 12);
69
70 ns->bvec_cache = kmem_cache_create("nvmet-bvec",
71 NVMET_MAX_MPOOL_BVEC * sizeof(struct bio_vec),
72 0, SLAB_HWCACHE_ALIGN, NULL);
73 if (!ns->bvec_cache) {
74 ret = -ENOMEM;
75 goto err;
76 }
77
78 ns->bvec_pool = mempool_create(NVMET_MIN_MPOOL_OBJ, mempool_alloc_slab,
79 mempool_free_slab, ns->bvec_cache);
80
81 if (!ns->bvec_pool) {
82 ret = -ENOMEM;
83 goto err;
84 }
85
86 return ret;
87 err:
88 ns->size = 0;
89 ns->blksize_shift = 0;
90 nvmet_file_ns_disable(ns);
91 return ret;
92 }
93

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip