All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Cc: Zorro Lang <zlang@redhat.com>,
	fstests@vger.kernel.org, fdmanana@suse.com,
	ritesh.list@gmail.com, naohiro.aota@wdc.com, wqu@suse.com
Subject: Re: [PATCH 2/6] common/rc: Add _sysfs_queue_path helper with partition support
Date: Fri, 10 Apr 2026 09:50:14 -0700	[thread overview]
Message-ID: <20260410165014.GQ6212@frogsfrogsfrogs> (raw)
In-Reply-To: <b88d249da588e8caf671088b34ced493e494d595.1775802601.git.ojaswin@linux.ibm.com>

On Fri, Apr 10, 2026 at 12:06:02PM +0530, Ojaswin Mujoo wrote:
> Add a generic helper function to get the sysfs queue path for block
> devices, properly handling partitions. Partitions don't have their own
> queue directory in sysfs - they inherit from their parent device.
> 
> This helper checks if a device is a partition and returns the parent
> device's queue path accordingly, making it easier to access queue
> attributes for both whole disks and partitions.
> 
> Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>

Excellent!
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  common/rc | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/common/rc b/common/rc
> index 5fe44e21..d7db5db1 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -5172,6 +5172,30 @@ _sysfs_dev()
>  	echo /sys/dev/block/$maj:$min
>  }
>  
> +# Get the sysfs queue path for a block device, handling partitions correctly.
> +_sysfs_queue_path()
> +{
> +	local dev parent
> +	dev=$(_short_dev "$1")
> +
> +	# For partitions, queue details are in the parent device's sysfs dir
> +	if [ -e "/sys/class/block/$dev/partition" ]; then
> +		parent=$(basename "$(readlink -f /sys/class/block/$dev/..)")
> +	else
> +		parent="$dev"
> +	fi
> +
> +	local queue_path="/sys/block/$parent/queue"
> +
> +	# Verify the path exists before returning
> +	if [ -e "$queue_path" ]; then
> +		echo "$queue_path"
> +		return 0
> +	else
> +		return 1
> +	fi
> +}
> +
>  # Get the minimum block size of a file.  Usually this is the
>  # minimum fs block size, but some filesystems (ocfs2) do block
>  # mappings in larger units.
> -- 
> 2.53.0
> 
> 

  reply	other threads:[~2026-04-10 16:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10  6:36 [PATCH v2 0/6] Atomic write test fixes & refactoring Ojaswin Mujoo
2026-04-10  6:36 ` [PATCH 1/6] ext4/061,062: Minor fixes and refactoring Ojaswin Mujoo
2026-04-14  9:52   ` Disha Goel
2026-04-10  6:36 ` [PATCH 2/6] common/rc: Add _sysfs_queue_path helper with partition support Ojaswin Mujoo
2026-04-10 16:50   ` Darrick J. Wong [this message]
2026-04-10  6:36 ` [PATCH 3/6] generic/765: Fix sysfs queue path for nvme partitions Ojaswin Mujoo
2026-04-10 16:50   ` Darrick J. Wong
2026-04-14  9:58   ` Disha Goel
2026-04-10  6:36 ` [PATCH 4/6] generic/765: Ignore mkfs warning Ojaswin Mujoo
2026-04-10 16:54   ` Darrick J. Wong
2026-04-12 17:08     ` Ojaswin Mujoo
2026-04-13  9:04       ` Ojaswin Mujoo
2026-04-13 16:21         ` Darrick J. Wong
2026-04-13 20:42           ` Theodore Tso
2026-04-13 23:28             ` Darrick J. Wong
2026-04-15 18:52             ` Ojaswin Mujoo
2026-04-16 15:55             ` Zorro Lang
2026-04-12 19:23     ` Zorro Lang
2026-04-13  9:09       ` Ojaswin Mujoo
2026-04-14 10:02   ` Disha Goel
2026-04-10  6:36 ` [PATCH 5/6] generic/775: Fix an infinite loop due to variable name clash Ojaswin Mujoo
2026-04-10 16:51   ` Darrick J. Wong
2026-04-14 10:05   ` Disha Goel
2026-04-10  6:36 ` [PATCH 6/6] treewide: Use _sysfs_queue_path helper in all queue access locations Ojaswin Mujoo
2026-04-10 16:52   ` Darrick J. Wong

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=20260410165014.GQ6212@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=fdmanana@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=wqu@suse.com \
    --cc=zlang@redhat.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.