From: Chuck Lever III <chuck.lever@oracle.com>
To: Xiu Jianfeng <xiujianfeng@huawei.com>
Cc: Jeff Layton <jlayton@kernel.org>,
Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] NFSD: Use struct_size() helpler in alloc_session()
Date: Fri, 11 Nov 2022 15:06:23 +0000 [thread overview]
Message-ID: <0B29DB16-0E08-4936-9847-09D156933CD7@oracle.com> (raw)
In-Reply-To: <20221111091835.151942-1-xiujianfeng@huawei.com>
> On Nov 11, 2022, at 4:18 AM, Xiu Jianfeng <xiujianfeng@huawei.com> wrote:
>
> Use struct_size() helper to simplify the code, no functional changes.
>
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Applied to nfsd's for-next tree. Thanks!
> ---
> fs/nfsd/nfs4state.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 2ec981fd2985..97badca3135e 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -1833,13 +1833,12 @@ static struct nfsd4_session *alloc_session(struct nfsd4_channel_attrs *fattrs,
> int numslots = fattrs->maxreqs;
> int slotsize = slot_bytes(fattrs);
> struct nfsd4_session *new;
> - int mem, i;
> + int i;
>
> - BUILD_BUG_ON(NFSD_MAX_SLOTS_PER_SESSION * sizeof(struct nfsd4_slot *)
> - + sizeof(struct nfsd4_session) > PAGE_SIZE);
> - mem = numslots * sizeof(struct nfsd4_slot *);
> + BUILD_BUG_ON(struct_size(new, se_slots, NFSD_MAX_SLOTS_PER_SESSION)
> + > PAGE_SIZE);
>
> - new = kzalloc(sizeof(*new) + mem, GFP_KERNEL);
> + new = kzalloc(struct_size(new, se_slots, numslots), GFP_KERNEL);
> if (!new)
> return NULL;
> /* allocate each struct nfsd4_slot and data cache in one piece */
> --
> 2.17.1
>
--
Chuck Lever
prev parent reply other threads:[~2022-11-11 15:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 9:18 Xiu Jianfeng
2022-11-11 14:50 ` Jeff Layton
2022-11-11 15:06 ` Chuck Lever III [this message]
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=0B29DB16-0E08-4936-9847-09D156933CD7@oracle.com \
--to=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=xiujianfeng@huawei.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
all inboxes | Powered by JetHome®