Skip to content

Commit 9936f2a

Browse files
kinglongmeeJ. Bruce Fields
authored andcommitted
sunrpc: Store cache_detail in seq_file's private directly
Cleanup. Just store cache_detail in seq_file's private, an allocated handle is redundant. v8, same as v6. Signed-off-by: Kinglong Mee <[email protected]> Reviewed-by: NeilBrown <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 7ba6cad commit 9936f2a

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

net/sunrpc/cache.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,18 +1270,13 @@ EXPORT_SYMBOL_GPL(qword_get);
12701270
* get a header, then pass each real item in the cache
12711271
*/
12721272

1273-
struct handle {
1274-
struct cache_detail *cd;
1275-
};
1276-
12771273
static void *c_start(struct seq_file *m, loff_t *pos)
12781274
__acquires(cd->hash_lock)
12791275
{
12801276
loff_t n = *pos;
12811277
unsigned int hash, entry;
12821278
struct cache_head *ch;
1283-
struct cache_detail *cd = ((struct handle*)m->private)->cd;
1284-
1279+
struct cache_detail *cd = m->private;
12851280

12861281
read_lock(&cd->hash_lock);
12871282
if (!n--)
@@ -1308,7 +1303,7 @@ static void *c_next(struct seq_file *m, void *p, loff_t *pos)
13081303
{
13091304
struct cache_head *ch = p;
13101305
int hash = (*pos >> 32);
1311-
struct cache_detail *cd = ((struct handle*)m->private)->cd;
1306+
struct cache_detail *cd = m->private;
13121307

13131308
if (p == SEQ_START_TOKEN)
13141309
hash = 0;
@@ -1334,14 +1329,14 @@ static void *c_next(struct seq_file *m, void *p, loff_t *pos)
13341329
static void c_stop(struct seq_file *m, void *p)
13351330
__releases(cd->hash_lock)
13361331
{
1337-
struct cache_detail *cd = ((struct handle*)m->private)->cd;
1332+
struct cache_detail *cd = m->private;
13381333
read_unlock(&cd->hash_lock);
13391334
}
13401335

13411336
static int c_show(struct seq_file *m, void *p)
13421337
{
13431338
struct cache_head *cp = p;
1344-
struct cache_detail *cd = ((struct handle*)m->private)->cd;
1339+
struct cache_detail *cd = m->private;
13451340

13461341
if (p == SEQ_START_TOKEN)
13471342
return cd->cache_show(m, cd, NULL);
@@ -1373,24 +1368,27 @@ static const struct seq_operations cache_content_op = {
13731368
static int content_open(struct inode *inode, struct file *file,
13741369
struct cache_detail *cd)
13751370
{
1376-
struct handle *han;
1371+
struct seq_file *seq;
1372+
int err;
13771373

13781374
if (!cd || !try_module_get(cd->owner))
13791375
return -EACCES;
1380-
han = __seq_open_private(file, &cache_content_op, sizeof(*han));
1381-
if (han == NULL) {
1376+
1377+
err = seq_open(file, &cache_content_op);
1378+
if (err) {
13821379
module_put(cd->owner);
1383-
return -ENOMEM;
1380+
return err;
13841381
}
13851382

1386-
han->cd = cd;
1383+
seq = file->private_data;
1384+
seq->private = cd;
13871385
return 0;
13881386
}
13891387

13901388
static int content_release(struct inode *inode, struct file *file,
13911389
struct cache_detail *cd)
13921390
{
1393-
int ret = seq_release_private(inode, file);
1391+
int ret = seq_release(inode, file);
13941392
module_put(cd->owner);
13951393
return ret;
13961394
}

0 commit comments

Comments
 (0)