Re: [PATCH] nvmet: add revalidation support to bdev and file backed namespaces

From: Christoph Hellwig
Date: Fri Apr 03 2020 - 02:43:35 EST


On Thu, Apr 02, 2020 at 09:30:52PM +0200, Anthony Iliopoulos wrote:
> Add support for detecting capacity changes on nvmet blockdev and file
> backed namespaces. This allows for emulating and testing online resizing
> of nvme devices and filesystems on top.
>
> Signed-off-by: Anthony Iliopoulos <ailiop@xxxxxxxx>

I vaguely remember seeing a very similar patch before, is this a repost?

> +void nvmet_bdev_ns_revalidate(struct nvmet_ns *ns)
> +{
> + loff_t size;
> +
> + size = i_size_read(ns->bdev->bd_inode);
> +
> + if (ns->size != size)
> + ns->size = size;

This can be:

ns->size = i_size_read(ns->bdev->bd_inode);

> +void nvmet_file_ns_revalidate(struct nvmet_ns *ns)
> +{
> + struct kstat stat;
> +
> + if (!ns->file)
> + return;

Shouldn't this always be non-NULL?

> +
> + if (vfs_getattr(&ns->file->f_path,
> + &stat, STATX_SIZE, AT_STATX_FORCE_SYNC))
> + return;

Use up the full line:

if (vfs_getattr(&ns->file->f_path, &stat, STATX_SIZE,
AT_STATX_FORCE_SYNC))

Also shouldn't there be error handling? If we can't stat the file
the namespace is toast.