Skip to content

Commit 4a55d36

Browse files
committed
Merge tag 'afs-next-20191121' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
Pull AFS updates from David Howells: "Minor cleanups and fix: - Minor fix to make some debugging statements display information from the correct iov_iter. - Rename some members and variables to make things more obvious or consistent. - Provide a helper to wrap increments of the usage count on the afs_read struct. - Use scnprintf() to print into a stack buffer rather than sprintf(). - Remove some set but unused variables" * tag 'afs-next-20191121' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: afs: Remove set but not used variable 'ret' afs: Remove set but not used variables 'before', 'after' afs: xattr: use scnprintf afs: Introduce an afs_get_read() refcount helper afs: Rename desc -> req in afs_fetch_data() afs: Switch the naming of call->iter and call->_iter afs: Use call->_iter not &call->iter in debugging statements
2 parents 50b8b3f + 4fe171b commit 4a55d36

File tree

10 files changed

+50
-54
lines changed

10 files changed

+50
-54
lines changed

fs/afs/cmservice.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,14 @@ static int afs_deliver_cb_callback(struct afs_call *call)
342342
if (call->count2 != call->count && call->count2 != 0)
343343
return afs_protocol_error(call, -EBADMSG,
344344
afs_eproto_cb_count);
345-
call->_iter = &call->iter;
346-
iov_iter_discard(&call->iter, READ, call->count2 * 3 * 4);
345+
call->iter = &call->def_iter;
346+
iov_iter_discard(&call->def_iter, READ, call->count2 * 3 * 4);
347347
call->unmarshall++;
348348

349349
/* Fall through */
350350
case 4:
351351
_debug("extract discard %zu/%u",
352-
iov_iter_count(&call->iter), call->count2 * 3 * 4);
352+
iov_iter_count(call->iter), call->count2 * 3 * 4);
353353

354354
ret = afs_extract_data(call, false);
355355
if (ret < 0)

fs/afs/dir_edit.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,11 @@ static int afs_find_contig_bits(union afs_xdr_dir_block *block, unsigned int nr_
6868
static void afs_set_contig_bits(union afs_xdr_dir_block *block,
6969
int bit, unsigned int nr_slots)
7070
{
71-
u64 mask, before, after;
71+
u64 mask;
7272

7373
mask = (1 << nr_slots) - 1;
7474
mask <<= bit;
7575

76-
before = *(u64 *)block->hdr.bitmap;
77-
7876
block->hdr.bitmap[0] |= (u8)(mask >> 0 * 8);
7977
block->hdr.bitmap[1] |= (u8)(mask >> 1 * 8);
8078
block->hdr.bitmap[2] |= (u8)(mask >> 2 * 8);
@@ -83,8 +81,6 @@ static void afs_set_contig_bits(union afs_xdr_dir_block *block,
8381
block->hdr.bitmap[5] |= (u8)(mask >> 5 * 8);
8482
block->hdr.bitmap[6] |= (u8)(mask >> 6 * 8);
8583
block->hdr.bitmap[7] |= (u8)(mask >> 7 * 8);
86-
87-
after = *(u64 *)block->hdr.bitmap;
8884
}
8985

9086
/*
@@ -93,13 +89,11 @@ static void afs_set_contig_bits(union afs_xdr_dir_block *block,
9389
static void afs_clear_contig_bits(union afs_xdr_dir_block *block,
9490
int bit, unsigned int nr_slots)
9591
{
96-
u64 mask, before, after;
92+
u64 mask;
9793

9894
mask = (1 << nr_slots) - 1;
9995
mask <<= bit;
10096

101-
before = *(u64 *)block->hdr.bitmap;
102-
10397
block->hdr.bitmap[0] &= ~(u8)(mask >> 0 * 8);
10498
block->hdr.bitmap[1] &= ~(u8)(mask >> 1 * 8);
10599
block->hdr.bitmap[2] &= ~(u8)(mask >> 2 * 8);
@@ -108,8 +102,6 @@ static void afs_clear_contig_bits(union afs_xdr_dir_block *block,
108102
block->hdr.bitmap[5] &= ~(u8)(mask >> 5 * 8);
109103
block->hdr.bitmap[6] &= ~(u8)(mask >> 6 * 8);
110104
block->hdr.bitmap[7] &= ~(u8)(mask >> 7 * 8);
111-
112-
after = *(u64 *)block->hdr.bitmap;
113105
}
114106

115107
/*

fs/afs/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static void afs_file_readpage_read_complete(struct page *page,
223223
/*
224224
* Fetch file data from the volume.
225225
*/
226-
int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *desc)
226+
int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *req)
227227
{
228228
struct afs_fs_cursor fc;
229229
struct afs_status_cb *scb;
@@ -246,7 +246,7 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *de
246246

247247
while (afs_select_fileserver(&fc)) {
248248
fc.cb_break = afs_calc_vnode_cb_break(vnode);
249-
afs_fs_fetch_data(&fc, scb, desc);
249+
afs_fs_fetch_data(&fc, scb, req);
250250
}
251251

252252
afs_check_for_remote_deletion(&fc, vnode);
@@ -257,7 +257,7 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *de
257257

258258
if (ret == 0) {
259259
afs_stat_v(vnode, n_fetches);
260-
atomic_long_add(desc->actual_len,
260+
atomic_long_add(req->actual_len,
261261
&afs_v2net(vnode)->n_fetch_bytes);
262262
}
263263

fs/afs/fsclient.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
323323
int ret;
324324

325325
_enter("{%u,%zu/%llu}",
326-
call->unmarshall, iov_iter_count(&call->iter), req->actual_len);
326+
call->unmarshall, iov_iter_count(call->iter), req->actual_len);
327327

328328
switch (call->unmarshall) {
329329
case 0:
@@ -363,14 +363,14 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
363363
call->bvec[0].bv_len = size;
364364
call->bvec[0].bv_offset = req->offset;
365365
call->bvec[0].bv_page = req->pages[req->index];
366-
iov_iter_bvec(&call->iter, READ, call->bvec, 1, size);
366+
iov_iter_bvec(&call->def_iter, READ, call->bvec, 1, size);
367367
ASSERTCMP(size, <=, PAGE_SIZE);
368368
/* Fall through */
369369

370370
/* extract the returned data */
371371
case 2:
372372
_debug("extract data %zu/%llu",
373-
iov_iter_count(&call->iter), req->remain);
373+
iov_iter_count(call->iter), req->remain);
374374

375375
ret = afs_extract_data(call, true);
376376
if (ret < 0)
@@ -398,7 +398,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
398398

399399
case 3:
400400
_debug("extract discard %zu/%llu",
401-
iov_iter_count(&call->iter), req->actual_len - req->len);
401+
iov_iter_count(call->iter), req->actual_len - req->len);
402402

403403
ret = afs_extract_data(call, true);
404404
if (ret < 0)
@@ -490,7 +490,7 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc,
490490
call->key = fc->key;
491491
call->out_scb = scb;
492492
call->out_volsync = NULL;
493-
call->read_request = req;
493+
call->read_request = afs_get_read(req);
494494

495495
/* marshall the parameters */
496496
bp = call->request;
@@ -503,7 +503,6 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc,
503503
bp[6] = 0;
504504
bp[7] = htonl(lower_32_bits(req->len));
505505

506-
refcount_inc(&req->usage);
507506
afs_use_fs_server(call, fc->cbi);
508507
trace_afs_make_fs_call(call, &vnode->fid);
509508
afs_set_fc_call(call, fc);
@@ -540,7 +539,7 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc,
540539
call->key = fc->key;
541540
call->out_scb = scb;
542541
call->out_volsync = NULL;
543-
call->read_request = req;
542+
call->read_request = afs_get_read(req);
544543

545544
/* marshall the parameters */
546545
bp = call->request;
@@ -551,7 +550,6 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc,
551550
bp[4] = htonl(lower_32_bits(req->pos));
552551
bp[5] = htonl(lower_32_bits(req->len));
553552

554-
refcount_inc(&req->usage);
555553
afs_use_fs_server(call, fc->cbi);
556554
trace_afs_make_fs_call(call, &vnode->fid);
557555
afs_set_fc_call(call, fc);
@@ -1852,7 +1850,7 @@ static int afs_deliver_fs_get_capabilities(struct afs_call *call)
18521850
u32 count;
18531851
int ret;
18541852

1855-
_enter("{%u,%zu}", call->unmarshall, iov_iter_count(&call->iter));
1853+
_enter("{%u,%zu}", call->unmarshall, iov_iter_count(call->iter));
18561854

18571855
switch (call->unmarshall) {
18581856
case 0:

fs/afs/internal.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ struct afs_call {
115115
struct afs_vnode *lvnode; /* vnode being locked */
116116
void *request; /* request data (first part) */
117117
struct address_space *mapping; /* Pages being written from */
118-
struct iov_iter iter; /* Buffer iterator */
119-
struct iov_iter *_iter; /* Iterator currently in use */
120-
union { /* Convenience for ->iter */
118+
struct iov_iter def_iter; /* Default buffer/data iterator */
119+
struct iov_iter *iter; /* Iterator currently in use */
120+
union { /* Convenience for ->def_iter */
121121
struct kvec kvec[1];
122122
struct bio_vec bvec[1];
123123
};
@@ -934,6 +934,12 @@ extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *);
934934
extern int afs_page_filler(void *, struct page *);
935935
extern void afs_put_read(struct afs_read *);
936936

937+
static inline struct afs_read *afs_get_read(struct afs_read *req)
938+
{
939+
refcount_inc(&req->usage);
940+
return req;
941+
}
942+
937943
/*
938944
* flock.c
939945
*/
@@ -1136,7 +1142,7 @@ static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t si
11361142
{
11371143
call->kvec[0].iov_base = buf;
11381144
call->kvec[0].iov_len = size;
1139-
iov_iter_kvec(&call->iter, READ, call->kvec, 1, size);
1145+
iov_iter_kvec(&call->def_iter, READ, call->kvec, 1, size);
11401146
}
11411147

11421148
static inline void afs_extract_to_tmp(struct afs_call *call)
@@ -1151,7 +1157,7 @@ static inline void afs_extract_to_tmp64(struct afs_call *call)
11511157

11521158
static inline void afs_extract_discard(struct afs_call *call, size_t size)
11531159
{
1154-
iov_iter_discard(&call->iter, READ, size);
1160+
iov_iter_discard(&call->def_iter, READ, size);
11551161
}
11561162

11571163
static inline void afs_extract_to_buf(struct afs_call *call, size_t size)

fs/afs/rxrpc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static struct afs_call *afs_alloc_call(struct afs_net *net,
152152
INIT_WORK(&call->async_work, afs_process_async_call);
153153
init_waitqueue_head(&call->waitq);
154154
spin_lock_init(&call->state_lock);
155-
call->_iter = &call->iter;
155+
call->iter = &call->def_iter;
156156

157157
o = atomic_inc_return(&net->nr_outstanding_calls);
158158
trace_afs_call(call, afs_call_trace_alloc, 1, o,
@@ -513,12 +513,12 @@ static void afs_deliver_to_call(struct afs_call *call)
513513
state == AFS_CALL_SV_AWAIT_ACK
514514
) {
515515
if (state == AFS_CALL_SV_AWAIT_ACK) {
516-
iov_iter_kvec(&call->iter, READ, NULL, 0, 0);
516+
iov_iter_kvec(&call->def_iter, READ, NULL, 0, 0);
517517
ret = rxrpc_kernel_recv_data(call->net->socket,
518-
call->rxcall, &call->iter,
518+
call->rxcall, &call->def_iter,
519519
false, &remote_abort,
520520
&call->service_id);
521-
trace_afs_receive_data(call, &call->iter, false, ret);
521+
trace_afs_receive_data(call, &call->def_iter, false, ret);
522522

523523
if (ret == -EINPROGRESS || ret == -EAGAIN)
524524
return;
@@ -859,7 +859,7 @@ static int afs_deliver_cm_op_id(struct afs_call *call)
859859
{
860860
int ret;
861861

862-
_enter("{%zu}", iov_iter_count(call->_iter));
862+
_enter("{%zu}", iov_iter_count(call->iter));
863863

864864
/* the operation ID forms the first four bytes of the request data */
865865
ret = afs_extract_data(call, true);
@@ -975,7 +975,7 @@ void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len)
975975
int afs_extract_data(struct afs_call *call, bool want_more)
976976
{
977977
struct afs_net *net = call->net;
978-
struct iov_iter *iter = call->_iter;
978+
struct iov_iter *iter = call->iter;
979979
enum afs_call_state state;
980980
u32 remote_abort = 0;
981981
int ret;

fs/afs/server.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static struct afs_server *afs_install_server(struct afs_net *net,
151151
const struct afs_addr_list *alist;
152152
struct afs_server *server;
153153
struct rb_node **pp, *p;
154-
int ret = -EEXIST, diff;
154+
int diff;
155155

156156
_enter("%p", candidate);
157157

@@ -196,7 +196,6 @@ static struct afs_server *afs_install_server(struct afs_net *net,
196196
hlist_add_head_rcu(&server->addr6_link, &net->fs_addresses6);
197197

198198
write_sequnlock(&net->fs_addr_lock);
199-
ret = 0;
200199

201200
exists:
202201
afs_get_server(server, afs_server_trace_get_install);

fs/afs/vlclient.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
185185
int i, ret;
186186

187187
_enter("{%u,%zu/%u}",
188-
call->unmarshall, iov_iter_count(call->_iter), call->count);
188+
call->unmarshall, iov_iter_count(call->iter), call->count);
189189

190190
switch (call->unmarshall) {
191191
case 0:
@@ -316,7 +316,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)
316316
int ret;
317317

318318
_enter("{%u,%zu/%u}",
319-
call->unmarshall, iov_iter_count(call->_iter), call->count);
319+
call->unmarshall, iov_iter_count(call->iter), call->count);
320320

321321
switch (call->unmarshall) {
322322
case 0:
@@ -425,7 +425,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
425425
int ret;
426426

427427
_enter("{%u,%zu,%u}",
428-
call->unmarshall, iov_iter_count(call->_iter), call->count2);
428+
call->unmarshall, iov_iter_count(call->iter), call->count2);
429429

430430
switch (call->unmarshall) {
431431
case 0:

fs/afs/xattr.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ static int afs_xattr_get_yfs(const struct xattr_handler *handler,
228228
break;
229229
case 1:
230230
data = buf;
231-
dsize = snprintf(buf, sizeof(buf), "%u", yacl->inherit_flag);
231+
dsize = scnprintf(buf, sizeof(buf), "%u", yacl->inherit_flag);
232232
break;
233233
case 2:
234234
data = buf;
235-
dsize = snprintf(buf, sizeof(buf), "%u", yacl->num_cleaned);
235+
dsize = scnprintf(buf, sizeof(buf), "%u", yacl->num_cleaned);
236236
break;
237237
case 3:
238238
data = yacl->vol_acl->data;
@@ -370,13 +370,15 @@ static int afs_xattr_get_fid(const struct xattr_handler *handler,
370370
/* The volume ID is 64-bit, the vnode ID is 96-bit and the
371371
* uniquifier is 32-bit.
372372
*/
373-
len = sprintf(text, "%llx:", vnode->fid.vid);
373+
len = scnprintf(text, sizeof(text), "%llx:", vnode->fid.vid);
374374
if (vnode->fid.vnode_hi)
375-
len += sprintf(text + len, "%x%016llx",
376-
vnode->fid.vnode_hi, vnode->fid.vnode);
375+
len += scnprintf(text + len, sizeof(text) - len, "%x%016llx",
376+
vnode->fid.vnode_hi, vnode->fid.vnode);
377377
else
378-
len += sprintf(text + len, "%llx", vnode->fid.vnode);
379-
len += sprintf(text + len, ":%x", vnode->fid.unique);
378+
len += scnprintf(text + len, sizeof(text) - len, "%llx",
379+
vnode->fid.vnode);
380+
len += scnprintf(text + len, sizeof(text) - len, ":%x",
381+
vnode->fid.unique);
380382

381383
if (size == 0)
382384
return len;

fs/afs/yfsclient.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
441441
int ret;
442442

443443
_enter("{%u,%zu/%llu}",
444-
call->unmarshall, iov_iter_count(&call->iter), req->actual_len);
444+
call->unmarshall, iov_iter_count(call->iter), req->actual_len);
445445

446446
switch (call->unmarshall) {
447447
case 0:
@@ -476,14 +476,14 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
476476
call->bvec[0].bv_len = size;
477477
call->bvec[0].bv_offset = req->offset;
478478
call->bvec[0].bv_page = req->pages[req->index];
479-
iov_iter_bvec(&call->iter, READ, call->bvec, 1, size);
479+
iov_iter_bvec(&call->def_iter, READ, call->bvec, 1, size);
480480
ASSERTCMP(size, <=, PAGE_SIZE);
481481
/* Fall through */
482482

483483
/* extract the returned data */
484484
case 2:
485485
_debug("extract data %zu/%llu",
486-
iov_iter_count(&call->iter), req->remain);
486+
iov_iter_count(call->iter), req->remain);
487487

488488
ret = afs_extract_data(call, true);
489489
if (ret < 0)
@@ -511,7 +511,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
511511

512512
case 3:
513513
_debug("extract discard %zu/%llu",
514-
iov_iter_count(&call->iter), req->actual_len - req->len);
514+
iov_iter_count(call->iter), req->actual_len - req->len);
515515

516516
ret = afs_extract_data(call, true);
517517
if (ret < 0)
@@ -605,7 +605,7 @@ int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_status_cb *scb,
605605
call->key = fc->key;
606606
call->out_scb = scb;
607607
call->out_volsync = NULL;
608-
call->read_request = req;
608+
call->read_request = afs_get_read(req);
609609

610610
/* marshall the parameters */
611611
bp = call->request;
@@ -616,7 +616,6 @@ int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_status_cb *scb,
616616
bp = xdr_encode_u64(bp, req->len);
617617
yfs_check_req(call, bp);
618618

619-
refcount_inc(&req->usage);
620619
afs_use_fs_server(call, fc->cbi);
621620
trace_afs_make_fs_call(call, &vnode->fid);
622621
afs_set_fc_call(call, fc);

0 commit comments

Comments
 (0)