All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yongpeng Yang" <yangyongpeng.storage@gmail.com>,
	agk@redhat.com, bmarzins@redhat.com, dm-devel@lists.linux.dev,
	mpatocka@redhat.com, snitzer@kernel.org
Cc: yangyongpeng@xiaomi.com
Subject: Re: [PATCH v2 3/4] dm-verity: size the hash retain target from the hash area
Date: Wed, 18 Nov 2026 17:50:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-221697@kernel.org> (raw)
In-Reply-To: <20261118172133.689163-5-yangyongpeng.storage@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] dm-verity: missing return on kobject_add() error in
  verity_presuspend_undo()
- [Low] dm-verity: redundant post-definition
  verity_register_bufio_sysfs() prototype
- [Low] dm-verity: dead code and redundant kobject reallocation in
  verity_resume()
--

commit 2adf10b9bb56217937bcf599cad99cc4d02fedf6
Author: Yongpeng Yang <yangyongpeng@xiaomi.com>

dm-verity: size the hash retain target from the hash area

This commit sets the default dm-bufio retain target for a dm-verity hash
client to a configurable percentage of the hash area and publishes the
dm-bufio clients in sysfs under /sys/block/dm-N/dm-bufio/.

> diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
> index 6d589867623c0..15dee27d58a7a 100644
> --- a/drivers/md/dm-verity-target.c
> +++ b/drivers/md/dm-verity-target.c

[ ... ]

> @@ -1797,6 +1825,49 @@ static inline void verity_security_clear_integrity(struct dm_target *ti)
>  
>  #endif /* CONFIG_SECURITY */
>  
> +/* Detach the dm-bufio directories from sysfs, keeping the kobjects. */
> +static void verity_detach_bufio_sysfs(struct dm_verity *v)
> +{
> +	dm_bufio_client_sysfs_detach(v->bufio);
> +	if (verity_fec_is_enabled(v)) {
> +		dm_bufio_client_sysfs_detach(v->fec->bufio);
> +		dm_bufio_client_sysfs_detach(v->fec->data_bufio);
> +	}
> +
> +	if (v->bufio_kobj && v->bufio_kobj->state_in_sysfs)
> +		kobject_del(v->bufio_kobj);
> +}
> +
> +/*
> + * Free the directory names before a table reload resumes a new
> + * instance.  Presuspend runs before the queue is frozen, so the kernfs
> + * drain cannot block on I/O.
> + */
> +static void verity_presuspend(struct dm_target *ti)
> +{
> +	verity_detach_bufio_sysfs(ti->private);
> +}
> +
> +static void verity_presuspend_undo(struct dm_target *ti)
> +{
> +	struct dm_verity *v = ti->private;
> +	struct mapped_device *md = dm_table_get_md(v->ti->table);
> +	struct kobject *parent = &disk_to_dev(dm_disk(md))->kobj;
> +
> +	if (!v->bufio_kobj)
> +		return;
> +
> +	if (!v->bufio_kobj->state_in_sysfs &&
> +	    kobject_add(v->bufio_kobj, parent, "%s", "dm-bufio"))
> +		DMERR("cannot re-attach dm-bufio sysfs directory");
> +
> +	(void)dm_bufio_client_sysfs_add(v->bufio, v->bufio_kobj, "hash");
> +	if (verity_fec_is_enabled(v)) {
> +		(void)dm_bufio_client_sysfs_add(v->fec->bufio, v->bufio_kobj, "fec");
> +		(void)dm_bufio_client_sysfs_add(v->fec->data_bufio, v->bufio_kobj, "fec-data");
> +	}
> +}

[Severity: Low]
Should verity_presuspend_undo() return early when kobject_add() fails to
re-attach v->bufio_kobj?  Falling through passes the unattached
v->bufio_kobj (with a NULL kernfs node) as the parent to
dm_bufio_client_sysfs_add(), causing each child registration to fail with
-ENOENT and emit additional kobject error messages.  Also, the client
registration sequence here duplicates verity_register_bufio_sysfs().

>  static void verity_postsuspend(struct dm_target *ti)
>  {
>  	struct dm_verity *v = ti->private;
> @@ -1806,6 +1877,53 @@ static void verity_postsuspend(struct dm_target *ti)
>  	verity_security_clear_integrity(ti);
>  }
>  
> +/*
> + * Publish the bufio clients under /sys/block/dm-N/dm-bufio/.  This runs
> + * from ->resume, not ->ctr, because the dm device's block device does not
> + * exist until the table is loaded.
> + */
> +static void verity_register_bufio_sysfs(struct dm_verity *v)
> +{
> +	struct mapped_device *md = dm_table_get_md(v->ti->table);
> +	struct kobject *parent = &disk_to_dev(dm_disk(md))->kobj;
> +
> +	if (v->bufio_kobj)
> +		return;
> +
> +	v->bufio_kobj = kobject_create_and_add("dm-bufio", parent);
> +	if (!v->bufio_kobj) {
> +		DMERR("cannot create dm-bufio sysfs directory");
> +		return;
> +	}
> +
> +	if (dm_bufio_client_sysfs_add(v->bufio, v->bufio_kobj, "hash"))
> +		DMERR("cannot register hash bufio client in sysfs");
> +
> +	if (verity_fec_is_enabled(v)) {
> +		if (dm_bufio_client_sysfs_add(v->fec->bufio, v->bufio_kobj, "fec"))
> +			DMERR("cannot register FEC bufio client in sysfs");
> +		if (dm_bufio_client_sysfs_add(v->fec->data_bufio, v->bufio_kobj, "fec-data"))
> +			DMERR("cannot register FEC data bufio client in sysfs");
> +	}
> +}
> +
> +static void verity_resume(struct dm_target *ti)
> +{
> +	struct dm_verity *v = ti->private;
> +
> +	if (v->bufio_kobj) {
> +		/* detached by presuspend, or re-attached by presuspend_undo */
> +		if (v->bufio_kobj->state_in_sysfs)
> +			kobject_del(v->bufio_kobj);
> +		kobject_put(v->bufio_kobj);
> +		v->bufio_kobj = NULL;
> +	}
> +
> +	verity_register_bufio_sysfs(v);
> +}

[Severity: Low]
Why does verity_resume() drop and reallocate v->bufio_kobj instead of
re-attaching it?

The commit message notes that presuspend keeps the kobjects until the
table is destroyed, and verity_register_bufio_sysfs() checks if
v->bufio_kobj is already allocated, which is dead code because
verity_resume() is its only caller and always clears v->bufio_kobj first.
In addition, if v->bufio_kobj->state_in_sysfs were ever set on entry to
verity_resume(), calling kobject_del(v->bufio_kobj) without detaching the
child client kobjects first would leave their state_in_sysfs flags set and
cause the subsequent dm_bufio_client_sysfs_add() calls to fail with
-EBUSY.

> +
> +static void verity_register_bufio_sysfs(struct dm_verity *v);

[Severity: Low]
This isn't a bug, but this forward declaration of
verity_register_bufio_sysfs() is placed after both its definition and its
caller.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118172133.689163-2-yangyongpeng.storage@gmail.com?part=3

  reply	other threads:[~2026-11-18 17:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 17:21 [PATCH v2 0/4] dm-bufio: per-client retain target, sysfs and dm-verity cache control Yongpeng Yang
2026-11-18 17:21 ` [PATCH v2 1/4] dm-bufio: make the retain target per client Yongpeng Yang
2026-11-18 17:21 ` [PATCH v2 2/4] dm-bufio: allow exposing a client in sysfs under a caller-chosen kobject Yongpeng Yang
2026-11-18 17:57   ` sashiko-bot
2026-11-18 17:21 ` [PATCH v2 3/4] dm-verity: size the hash retain target from the hash area Yongpeng Yang
2026-11-18 17:50   ` sashiko-bot [this message]
2026-11-18 17:21 ` [PATCH v2 4/4] dm-verity: add messages to inspect, prefetch and drop hash blocks Yongpeng Yang
2026-11-18 17:43   ` sashiko-bot

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=sashiko-outbox-221697@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=mpatocka@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=snitzer@kernel.org \
    --cc=yangyongpeng.storage@gmail.com \
    --cc=yangyongpeng@xiaomi.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.