Skip to content

Commit f07044d

Browse files
committed
Merge tag 'nfsd-6.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
Pull nfsd fixes from Chuck Lever:: - Revert one v6.13 fix at the author's request (to be done differently) - Fix a minor problem with recent NFSv4.2 COPY enhancements - Fix an NFSv4.0 callback bug introduced in the v6.13 merge window * tag 'nfsd-6.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: nfsd: restore callback functionality for NFSv4.0 NFSD: fix management of pending async copies nfsd: Revert "nfsd: release svc_expkey/svc_export with rcu_work"
2 parents 4bbf902 + 7917f01 commit f07044d

File tree

4 files changed

+17
-35
lines changed

4 files changed

+17
-35
lines changed

fs/nfsd/export.c

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,15 @@
4040
#define EXPKEY_HASHMAX (1 << EXPKEY_HASHBITS)
4141
#define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1)
4242

43-
static void expkey_put_work(struct work_struct *work)
43+
static void expkey_put(struct kref *ref)
4444
{
45-
struct svc_expkey *key =
46-
container_of(to_rcu_work(work), struct svc_expkey, ek_rcu_work);
45+
struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref);
4746

4847
if (test_bit(CACHE_VALID, &key->h.flags) &&
4948
!test_bit(CACHE_NEGATIVE, &key->h.flags))
5049
path_put(&key->ek_path);
5150
auth_domain_put(key->ek_client);
52-
kfree(key);
53-
}
54-
55-
static void expkey_put(struct kref *ref)
56-
{
57-
struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref);
58-
59-
INIT_RCU_WORK(&key->ek_rcu_work, expkey_put_work);
60-
queue_rcu_work(system_wq, &key->ek_rcu_work);
51+
kfree_rcu(key, ek_rcu);
6152
}
6253

6354
static int expkey_upcall(struct cache_detail *cd, struct cache_head *h)
@@ -364,26 +355,16 @@ static void export_stats_destroy(struct export_stats *stats)
364355
EXP_STATS_COUNTERS_NUM);
365356
}
366357

367-
static void svc_export_put_work(struct work_struct *work)
358+
static void svc_export_put(struct kref *ref)
368359
{
369-
struct svc_export *exp =
370-
container_of(to_rcu_work(work), struct svc_export, ex_rcu_work);
371-
360+
struct svc_export *exp = container_of(ref, struct svc_export, h.ref);
372361
path_put(&exp->ex_path);
373362
auth_domain_put(exp->ex_client);
374363
nfsd4_fslocs_free(&exp->ex_fslocs);
375364
export_stats_destroy(exp->ex_stats);
376365
kfree(exp->ex_stats);
377366
kfree(exp->ex_uuid);
378-
kfree(exp);
379-
}
380-
381-
static void svc_export_put(struct kref *ref)
382-
{
383-
struct svc_export *exp = container_of(ref, struct svc_export, h.ref);
384-
385-
INIT_RCU_WORK(&exp->ex_rcu_work, svc_export_put_work);
386-
queue_rcu_work(system_wq, &exp->ex_rcu_work);
367+
kfree_rcu(exp, ex_rcu);
387368
}
388369

389370
static int svc_export_upcall(struct cache_detail *cd, struct cache_head *h)

fs/nfsd/export.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct svc_export {
7575
u32 ex_layout_types;
7676
struct nfsd4_deviceid_map *ex_devid_map;
7777
struct cache_detail *cd;
78-
struct rcu_work ex_rcu_work;
78+
struct rcu_head ex_rcu;
7979
unsigned long ex_xprtsec_modes;
8080
struct export_stats *ex_stats;
8181
};
@@ -92,7 +92,7 @@ struct svc_expkey {
9292
u32 ek_fsid[6];
9393

9494
struct path ek_path;
95-
struct rcu_work ek_rcu_work;
95+
struct rcu_head ek_rcu;
9696
};
9797

9898
#define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))

fs/nfsd/nfs4callback.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
11001100
args.authflavor = clp->cl_cred.cr_flavor;
11011101
clp->cl_cb_ident = conn->cb_ident;
11021102
} else {
1103-
if (!conn->cb_xprt)
1103+
if (!conn->cb_xprt || !ses)
11041104
return -EINVAL;
11051105
clp->cl_cb_session = ses;
11061106
args.bc_xprt = conn->cb_xprt;
@@ -1522,8 +1522,6 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb)
15221522
ses = c->cn_session;
15231523
}
15241524
spin_unlock(&clp->cl_lock);
1525-
if (!c)
1526-
return;
15271525

15281526
err = setup_callback_client(clp, &conn, ses);
15291527
if (err) {

fs/nfsd/nfs4proc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,6 @@ static void nfs4_put_copy(struct nfsd4_copy *copy)
13471347
{
13481348
if (!refcount_dec_and_test(&copy->refcount))
13491349
return;
1350-
atomic_dec(&copy->cp_nn->pending_async_copies);
13511350
kfree(copy->cp_src);
13521351
kfree(copy);
13531352
}
@@ -1870,6 +1869,7 @@ static int nfsd4_do_async_copy(void *data)
18701869
set_bit(NFSD4_COPY_F_COMPLETED, &copy->cp_flags);
18711870
trace_nfsd_copy_async_done(copy);
18721871
nfsd4_send_cb_offload(copy);
1872+
atomic_dec(&copy->cp_nn->pending_async_copies);
18731873
return 0;
18741874
}
18751875

@@ -1927,19 +1927,19 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
19271927
/* Arbitrary cap on number of pending async copy operations */
19281928
if (atomic_inc_return(&nn->pending_async_copies) >
19291929
(int)rqstp->rq_pool->sp_nrthreads)
1930-
goto out_err;
1930+
goto out_dec_async_copy_err;
19311931
async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL);
19321932
if (!async_copy->cp_src)
1933-
goto out_err;
1933+
goto out_dec_async_copy_err;
19341934
if (!nfs4_init_copy_state(nn, copy))
1935-
goto out_err;
1935+
goto out_dec_async_copy_err;
19361936
memcpy(&result->cb_stateid, &copy->cp_stateid.cs_stid,
19371937
sizeof(result->cb_stateid));
19381938
dup_copy_fields(copy, async_copy);
19391939
async_copy->copy_task = kthread_create(nfsd4_do_async_copy,
19401940
async_copy, "%s", "copy thread");
19411941
if (IS_ERR(async_copy->copy_task))
1942-
goto out_err;
1942+
goto out_dec_async_copy_err;
19431943
spin_lock(&async_copy->cp_clp->async_lock);
19441944
list_add(&async_copy->copies,
19451945
&async_copy->cp_clp->async_copies);
@@ -1954,6 +1954,9 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
19541954
trace_nfsd_copy_done(copy, status);
19551955
release_copy_files(copy);
19561956
return status;
1957+
out_dec_async_copy_err:
1958+
if (async_copy)
1959+
atomic_dec(&nn->pending_async_copies);
19571960
out_err:
19581961
if (nfsd4_ssc_is_inter(copy)) {
19591962
/*

0 commit comments

Comments
 (0)