linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Dickson <steved@redhat.com>
To: tbecker@redhat.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] nfsrahead: modify get_device_info logic
Date: Mon, 18 Aug 2025 09:03:20 -0400	[thread overview]
Message-ID: <7e8be3e3-f766-4120-8c8f-6ad5b715dcc8@redhat.com> (raw)
In-Reply-To: <20250812213822.403844-1-tbecker@redhat.com>

Hello,

On 8/12/25 5:38 PM, tbecker@redhat.com wrote:
> From: Thiago Becker <tbecker@redhat.com>
> 
> There are a few reports of failures by nfsrahead to set the read ahead
> when the nfs mount information is not available when the udev event
> fires. This was alleviated by retrying to read mountinfo multiple times,
> but some cases where still failing to find the device information. To
> further alleviate this issue, this patch adds a 50ms delay between
> attempts. To not incur into unecessary delays, the logic in
> get_device_info is reworked.
> 
> While we are in this, remove a second loop of reptitions of
> get_device_info.
> 
> Signed-off-by: Thiago Becker <tbecker@redhat.com>
> ---
>   tools/nfsrahead/main.c | 14 ++++++--------
>   1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c
> index 8a11cf1a..b7b889ff 100644
> --- a/tools/nfsrahead/main.c
> +++ b/tools/nfsrahead/main.c
> @@ -117,9 +117,11 @@ out_free_device_info:
>   
>   static int get_device_info(const char *device_number, struct device_info *device_info)
>   {
> -	int ret = ENOENT;
> -	for (int retry_count = 0; retry_count < 10 && ret != 0; retry_count++)
> +	int ret = get_mountinfo(device_number, device_info, MOUNTINFO_PATH);
> +	for (int retry_count = 0; retry_count < 5 && ret != 0; retry_count++) {
> +		usleep(50000);
>   		ret = get_mountinfo(device_number, device_info, MOUNTINFO_PATH);
> +	}
get_mountinfo() will error out with an errno value (ret != 0) so
how is how are error detected? What am I missing...

Also why was a value of 50000 used to sleep?

steved.

>   
>   	return ret;
>   }
> @@ -135,7 +137,7 @@ static int conf_get_readahead(const char *kind) {
>   
>   int main(int argc, char **argv)
>   {
> -	int ret = 0, retry, opt;
> +	int ret = 0, opt;
>   	struct device_info device;
>   	unsigned int readahead = 128, log_level, log_stderr = 0;
>   
> @@ -163,11 +165,7 @@ int main(int argc, char **argv)
>   	if ((argc - optind) != 1)
>   		xlog_err("expected the device number of a BDI; is udev ok?");
>   
> -	for (retry = 0; retry <= 10; retry++ )
> -		if ((ret = get_device_info(argv[optind], &device)) == 0)
> -			break;
> -
> -	if (ret != 0 || device.fstype == NULL) {
> +	if ((ret = get_device_info(argv[optind], &device)) != 0 || device.fstype == NULL) {
>   		xlog(D_GENERAL, "unable to find device %s\n", argv[optind]);
>   		goto out;
>   	}


  reply	other threads:[~2025-08-18 13:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-12 21:38 [PATCH] nfsrahead: modify get_device_info logic tbecker
2025-08-18 13:03 ` Steve Dickson [this message]
2025-08-26 20:41   ` Thiago Becker

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=7e8be3e3-f766-4120-8c8f-6ad5b715dcc8@redhat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tbecker@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 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).