From: Christoph Hellwig <hch@infradead.org>
To: Anuj Gupta <anuj20.g@samsung.com>
Cc: vincent.fu@samsung.com, jack@suse.cz, anuj1072538@gmail.com,
axboe@kernel.dk, viro@zeniv.linux.org.uk, brauner@kernel.org,
hch@infradead.org, martin.petersen@oracle.com,
ebiggers@kernel.org, adilger@dilger.ca,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
joshi.k@samsung.com
Subject: Re: [PATCH for-next v3 2/2] fs: add ioctl to query metadata and protection info capabilities
Date: Tue, 10 Jun 2025 20:53:00 -0700 [thread overview]
Message-ID: <aEj9nNEz7veOL7wL@infradead.org> (raw)
In-Reply-To: <20250610132254.6152-3-anuj20.g@samsung.com>
On Tue, Jun 10, 2025 at 06:52:54PM +0530, Anuj Gupta wrote:
> +int blk_get_meta_cap(struct block_device *bdev,
> + struct logical_block_metadata_cap __user *argp)
> +{
> + struct blk_integrity *bi = blk_get_integrity(bdev->bd_disk);
> + struct logical_block_metadata_cap meta_cap = {};
> +
> + if (!bi)
> + goto out;
So is returning an all zeroed structure really the expected interface?
It feels kinda unusual, but if we want to go with that for extensibility
it should probably frow a comment and some language in the man page to
explain what fields to check for support.
> + if (bi->csum_type == BLK_INTEGRITY_CSUM_NONE) {
> + /* treat entire tuple as opaque block tag */
> + meta_cap.lbmd_opaque_size = bi->tuple_size;
> + goto out;
Purely cosmetic, but the mix of this and the later switch looks a
bit odd. Instead I'd..
> + }
> + meta_cap.lbmd_pi_size = bi->pi_size;
> + meta_cap.lbmd_pi_offset = bi->pi_offset;
> + meta_cap.lbmd_opaque_size = bi->tuple_size - bi->pi_size;
> + if (meta_cap.lbmd_opaque_size && !bi->pi_offset)
> + meta_cap.lbmd_opaque_offset = bi->pi_size;
> +
> + meta_cap.lbmd_guard_tag_type = bi->csum_type;
... keep this in the common branch. All the assignment should do
the right thing even for the non-PI metadata case even if they
do a little extra work.
> + meta_cap.lbmd_app_tag_size = 2;
And then just guard this with:
if (bi->csum_type != BLK_INTEGRITY_CSUM_NONE)
meta_cap.lbmd_app_tag_size = 2;
> +
> +/*
> + * struct logical_block_metadata_cap - Logical block metadata
> + * @lbmd_flags: Bitmask of logical block metadata capability flags
> + * @lbmd_interval: The amount of data described by each unit of logical block metadata
> + * @lbmd_size: Size in bytes of the logical block metadata associated with each interval
> + * @lbmd_opaque_size: Size in bytes of the opaque block tag associated with each interval
> + * @lbmd_opaque_offset: Offset in bytes of the opaque block tag within the logical block metadata
> + * @lbmd_pi_size: Size in bytes of the T10 PI tuple associated with each interval
> + * @lbmd_pi_offset: Offset in bytes of T10 PI tuple within the logical block metadata
> + * @lbmd_pi_guard_tag_type: T10 PI guard tag type
> + * @lbmd_pi_app_tag_size: Size in bytes of the T10 PI application tag
> + * @lbmd_pi_ref_tag_size: Size in bytes of the T10 PI reference tag
> + * @lbmd_pi_storage_tag_size: Size in bytes of the T10 PI storage tag
> + * @lbmd_rsvd: Reserved for future use
I find this style of comment really hard to read due to the long
lines vs just comments next to the fields. But it's become
fashionable lately, so..
next prev parent reply other threads:[~2025-06-11 3:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250610132307epcas5p4c6c107e84642a1367600afe9167655b8@epcas5p4.samsung.com>
2025-06-10 13:22 ` [PATCH for-next v3 0/2] add ioctl to query metadata and protection info capabilities Anuj Gupta
[not found] ` <CGME20250610132312epcas5p20cdd1a3119df8ffc68770f06745e8481@epcas5p2.samsung.com>
2025-06-10 13:22 ` [PATCH for-next v3 1/2] block: introduce pi_size field in blk_integrity Anuj Gupta
2025-06-11 3:44 ` Christoph Hellwig
2025-06-13 1:51 ` Martin K. Petersen
[not found] ` <CGME20250610132317epcas5p442ce20c039224fb691ab0ba03fcb21e7@epcas5p4.samsung.com>
2025-06-10 13:22 ` [PATCH for-next v3 2/2] fs: add ioctl to query metadata and protection info capabilities Anuj Gupta
2025-06-11 3:53 ` Christoph Hellwig [this message]
2025-06-11 10:23 ` Christian Brauner
2025-06-12 5:15 ` Christoph Hellwig
2025-06-12 12:24 ` Christian Brauner
2025-06-18 5:56 ` Anuj gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aEj9nNEz7veOL7wL@infradead.org \
--to=hch@infradead.org \
--cc=adilger@dilger.ca \
--cc=anuj1072538@gmail.com \
--cc=anuj20.g@samsung.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=ebiggers@kernel.org \
--cc=jack@suse.cz \
--cc=joshi.k@samsung.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=vincent.fu@samsung.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).