From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/8] nfs: Add function to free packets
Date: Mon, 30 Mar 2020 11:12:03 +0200 [thread overview]
Message-ID: <20200330091210.18716-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20200330091210.18716-1-s.hauer@pengutronix.de>
Add to function to free packets rather than freeing them directly. We
will introduce received packet qeueuing with one of the next patches,
this patch is meant to make it better readable.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/nfs.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/fs/nfs.c b/fs/nfs.c
index 0ad07aa3f2..0d098f2a66 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -397,6 +397,11 @@ static int rpc_check_reply(struct packet *pkt, int rpc_prog,
return 0;
}
+static void nfs_free_packet(struct packet *packet)
+{
+ free(packet);
+}
+
/*
* rpc_req - synchronous RPC request
*/
@@ -472,7 +477,7 @@ again:
npriv->rpc_id, &nfserr);
if (!ret) {
if (rpc_prog == PROG_NFS && nfserr) {
- free(npriv->nfs_packet);
+ nfs_free_packet(npriv->nfs_packet);
return ERR_PTR(nfserr);
} else {
return npriv->nfs_packet;
@@ -505,7 +510,7 @@ static int rpc_lookup_req(struct nfs_priv *npriv, uint32_t prog, uint32_t ver)
port = ntoh32(net_read_uint32(nfs_packet->data + sizeof(struct rpc_reply)));
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
return port;
}
@@ -676,12 +681,12 @@ static int nfs_mount_req(struct nfs_priv *npriv)
if (npriv->rootfh.size > NFS3_FHSIZE) {
printf("%s: file handle too big: %lu\n",
__func__, (unsigned long)npriv->rootfh.size);
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
return -EIO;
}
memcpy(npriv->rootfh.data, p, npriv->rootfh.size);
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
return 0;
}
@@ -709,7 +714,7 @@ static void nfs_umount_req(struct nfs_priv *npriv)
nfs_packet = rpc_req(npriv, PROG_MOUNT, MOUNT_UMOUNT, data, len);
if (!IS_ERR(nfs_packet))
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
}
/*
@@ -777,7 +782,7 @@ static int nfs_lookup_req(struct nfs_priv *npriv, struct nfs_fh *fh,
nfs_read_post_op_attr(p, inode);
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
return 0;
}
@@ -857,7 +862,7 @@ static void *nfs_readdirattr_req(struct nfs_priv *npriv, struct nfs_dir *dir)
len = (void *)nfs_packet->data + nfs_packet->len - (void *)p;
if (!len) {
printf("%s: huh, no payload left\n", __func__);
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
return NULL;
}
@@ -865,7 +870,7 @@ static void *nfs_readdirattr_req(struct nfs_priv *npriv, struct nfs_dir *dir)
memcpy(buf, p, len);
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
xdr_init(&dir->stream, buf, len);
@@ -942,13 +947,13 @@ static int nfs_read_req(struct file_priv *priv, uint64_t offset,
p += 2;
if (readlen && !rlen && !eof) {
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
return -EIO;
}
kfifo_put(priv->fifo, (char *)p, rlen);
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
return 0;
}
@@ -1032,7 +1037,7 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh,
*target = xzalloc(len + 1);
memcpy(*target, p, len);
- free(nfs_packet);
+ nfs_free_packet(nfs_packet);
return 0;
}
--
2.26.0.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-03-30 9:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-30 9:12 [PATCH 0/8] NFS fixes Sascha Hauer
2020-03-30 9:12 ` Sascha Hauer [this message]
2020-03-30 9:12 ` [PATCH 2/8] nfs: Add missing free Sascha Hauer
2020-03-30 9:12 ` [PATCH 3/8] nfs: remove unnecessary check Sascha Hauer
2020-03-30 9:12 ` [PATCH 4/8] nfs: Fix rpc_check_reply() return value for stale packets Sascha Hauer
2020-03-30 9:12 ` [PATCH 5/8] nfs: Fix polling for packets Sascha Hauer
2020-03-30 9:12 ` [PATCH 6/8] nfs: queue received packets Sascha Hauer
2020-03-30 9:12 ` [PATCH 7/8] fs: nfs: don't maintain nfs dentries in dcache Sascha Hauer
2020-03-30 9:12 ` [PATCH 8/8] nfs: Do not allow to abort Sascha Hauer
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=20200330091210.18716-2-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox