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

kernel test robot lkp at intel.com
Wed May 12 07:59:12 PDT 2021


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: riscv-randconfig-r011-20210512 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a0fed635fe1701470062495a6ffee1c608f3f1bc)
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 riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # 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=clang make.cross W=1 ARCH=riscv 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>

All warnings (new ones prefixed by >>):

>> drivers/nvme/target/io-cmd-file.c:54:7: warning: incompatible pointer to integer conversion assigning to 'int' from 'struct file *' [-Wint-conversion]
                   ret = ns->file;
                       ^ ~~~~~~~~
>> drivers/nvme/target/io-cmd-file.c:56:18: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *' [-Wint-conversion]
                   return PTR_ERR(ret);
                                  ^~~
   include/linux/err.h:29:61: note: passing argument to parameter 'ptr' here
   static inline long __must_check PTR_ERR(__force const void *ptr)
                                                               ^
   2 warnings generated.


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@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 32777 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20210512/88e9fafb/attachment-0001.gz>


More information about the Linux-nvme mailing list