2022-10-26 08:24:26

by Jeff Layton

[permalink] [raw]
Subject: [PATCH 1/2] nfsd: make "gc" parameter a bool

This gets compared to the result of test_bit which may or may not always
exactly match what the bitfield holds. Bitfields in C can be unintuitive
to deal with. Make it a bool instead. This doesn't change the size of
the struct anyway.

Signed-off-by: Jeff Layton <[email protected]>
---
fs/nfsd/filecache.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index 106e99b24b6f..918d67cec1ad 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -63,7 +63,7 @@ struct nfsd_file_lookup_key {
struct net *net;
const struct cred *cred;
unsigned char need;
- unsigned char gc:1;
+ bool gc;
enum nfsd_file_lookup_type type;
};

@@ -1034,7 +1034,7 @@ nfsd_file_is_cached(struct inode *inode)
static __be32
nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
unsigned int may_flags, struct nfsd_file **pnf,
- bool open, int want_gc)
+ bool open, bool want_gc)
{
struct nfsd_file_lookup_key key = {
.type = NFSD_FILE_KEY_FULL,
@@ -1161,7 +1161,7 @@ __be32
nfsd_file_acquire_gc(struct svc_rqst *rqstp, struct svc_fh *fhp,
unsigned int may_flags, struct nfsd_file **pnf)
{
- return nfsd_file_do_acquire(rqstp, fhp, may_flags, pnf, true, 1);
+ return nfsd_file_do_acquire(rqstp, fhp, may_flags, pnf, true, true);
}

/**
@@ -1182,7 +1182,7 @@ __be32
nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
unsigned int may_flags, struct nfsd_file **pnf)
{
- return nfsd_file_do_acquire(rqstp, fhp, may_flags, pnf, true, 0);
+ return nfsd_file_do_acquire(rqstp, fhp, may_flags, pnf, true, false);
}

/**
--
2.37.3



2022-10-26 13:19:10

by Chuck Lever III

[permalink] [raw]
Subject: Re: [PATCH 1/2] nfsd: make "gc" parameter a bool



> On Oct 26, 2022, at 4:15 AM, Jeff Layton <[email protected]> wrote:
>
> This gets compared to the result of test_bit which may or may not always
> exactly match what the bitfield holds. Bitfields in C can be unintuitive
> to deal with. Make it a bool instead. This doesn't change the size of
> the struct anyway.
>
> Signed-off-by: Jeff Layton <[email protected]>

I've already done this in my tree, thought it was in the repo already!
Thanks for the nudge.


> ---
> fs/nfsd/filecache.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
> index 106e99b24b6f..918d67cec1ad 100644
> --- a/fs/nfsd/filecache.c
> +++ b/fs/nfsd/filecache.c
> @@ -63,7 +63,7 @@ struct nfsd_file_lookup_key {
> struct net *net;
> const struct cred *cred;
> unsigned char need;
> - unsigned char gc:1;
> + bool gc;
> enum nfsd_file_lookup_type type;
> };
>
> @@ -1034,7 +1034,7 @@ nfsd_file_is_cached(struct inode *inode)
> static __be32
> nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
> unsigned int may_flags, struct nfsd_file **pnf,
> - bool open, int want_gc)
> + bool open, bool want_gc)
> {
> struct nfsd_file_lookup_key key = {
> .type = NFSD_FILE_KEY_FULL,
> @@ -1161,7 +1161,7 @@ __be32
> nfsd_file_acquire_gc(struct svc_rqst *rqstp, struct svc_fh *fhp,
> unsigned int may_flags, struct nfsd_file **pnf)
> {
> - return nfsd_file_do_acquire(rqstp, fhp, may_flags, pnf, true, 1);
> + return nfsd_file_do_acquire(rqstp, fhp, may_flags, pnf, true, true);
> }
>
> /**
> @@ -1182,7 +1182,7 @@ __be32
> nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
> unsigned int may_flags, struct nfsd_file **pnf)
> {
> - return nfsd_file_do_acquire(rqstp, fhp, may_flags, pnf, true, 0);
> + return nfsd_file_do_acquire(rqstp, fhp, may_flags, pnf, true, false);
> }
>
> /**
> --
> 2.37.3
>

--
Chuck Lever