[pnfs] [PATCH] nfs41: do not malloc slot table while holding a spin_lock
Benny Halevy
bhalevy at panasas.com
Thu Mar 13 07:47:01 EDT 2008
Also, check that the slot table has not already been allocated.
Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
fs/nfs/nfs4proc.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index b2fb261..e9ce798 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4524,21 +4524,23 @@ int nfs4_init_slot_table(struct nfs4_channel *channel)
struct nfs4_slot *slot;
int ret = 0;
+ slot = kzalloc(channel->chan_attrs.max_reqs * sizeof(struct nfs4_slot),
+ GFP_ATOMIC);
+ if (!slot)
+ return -ENOMEM;
+
tbl = &channel->slot_table;
spin_lock(&tbl->slot_tbl_lock);
-
- tbl->max_slots = channel->chan_attrs.max_reqs;
-
- tbl->slots = kzalloc(channel->chan_attrs.max_reqs *
- sizeof(struct nfs4_slot), GFP_ATOMIC);
- if (!tbl->slots) {
- ret = -ENOMEM;
+ if (tbl->slots != NULL) {
+ kfree(slot);
goto out;
}
- for (i = 0; i < channel->chan_attrs.max_reqs; ++i) {
- slot = &tbl->slots[i];
+ tbl->max_slots = channel->chan_attrs.max_reqs;
+ tbl->slots = slot;
+
+ for (i = 0; i < channel->chan_attrs.max_reqs; ++i, ++slot) {
slot->slot_nr = i;
slot->seq_nr = 1;
slot->flags = 0;
--
1.5.3.3
More information about the pNFS
mailing list