From: Bart Van Assche <bvanassche@acm.org>
To: Honggang LI <honli@redhat.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH] srp_daemon: Use maximum initiator to target IU size
Date: Tue, 22 Oct 2019 15:10:26 -0700 [thread overview]
Message-ID: <5f664232-ca58-c25c-e9b1-e441c053c818@acm.org> (raw)
In-Reply-To: <20191022070025.GA20278@dhcp-128-227.nay.redhat.com>
On 2019-10-22 00:00, Honggang LI wrote:
> +static bool use_imm_data(void)
> +{
> +#ifdef __linux__
> + bool ret = false;
> + char flag = 0;
> + int cnt;
> + int fd = open("/sys/module/ib_srp/parameters/use_imm_data", O_RDONLY);
> +
> + if (fd < 0)
> + return false;
> + cnt = read(fd, &flag, 1);
> + if (cnt != 1)
> + return false;
> +
> + if (!strncmp(&flag, "Y", 1))
> + ret = true;
> + close(fd);
> + return ret;
> +#else
> + return false;
> +#endif
> +}
There is already plenty of Linux-specific code in srp_daemon. The #ifdef
__linux__ / #endif guard does not seem useful to me.
There is a file descriptor leak in the above function, namely if read()
returns another value than 1.
The use_imm_data kernel module parameter was introduced in kernel v5.0
(commit 882981f4a411; "RDMA/srp: Add support for immediate data"). The
max_it_iu_size will be introduced in kernel v5.5 (commit 547ed331bbe8;
"RDMA/srp: Add parse function for maximum initiator to target IU size").
So the above check will help for kernel versions before v5.0 but not for
kernel versions [v5.0..v5.5). If that is really what you want, please
explain this in a comment above the use_imm_data() function.
Thanks,
Bart.
next prev parent reply other threads:[~2019-10-22 22:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 4:41 [PATCH] srp_daemon: Use maximum initiator to target IU size Honggang LI
2019-10-18 4:57 ` Bart Van Assche
2019-10-18 15:22 ` Honggang LI
2019-10-18 17:10 ` Bart Van Assche
2019-10-22 7:00 ` Honggang LI
2019-10-22 22:10 ` Bart Van Assche [this message]
2019-10-23 3:06 ` Honggang LI
2019-10-23 15:33 ` Honggang LI
2019-10-24 2:13 ` Bart Van Assche
2019-10-24 13:18 ` Honggang LI
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=5f664232-ca58-c25c-e9b1-e441c053c818@acm.org \
--to=bvanassche@acm.org \
--cc=honli@redhat.com \
--cc=linux-rdma@vger.kernel.org \
/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.