diff options
-rw-r--r-- | net/sunrpc/cache.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 2928afffbb81..edec603abc17 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -1270,18 +1270,13 @@ EXPORT_SYMBOL_GPL(qword_get); | |||
1270 | * get a header, then pass each real item in the cache | 1270 | * get a header, then pass each real item in the cache |
1271 | */ | 1271 | */ |
1272 | 1272 | ||
1273 | struct handle { | ||
1274 | struct cache_detail *cd; | ||
1275 | }; | ||
1276 | |||
1277 | static void *c_start(struct seq_file *m, loff_t *pos) | 1273 | static void *c_start(struct seq_file *m, loff_t *pos) |
1278 | __acquires(cd->hash_lock) | 1274 | __acquires(cd->hash_lock) |
1279 | { | 1275 | { |
1280 | loff_t n = *pos; | 1276 | loff_t n = *pos; |
1281 | unsigned int hash, entry; | 1277 | unsigned int hash, entry; |
1282 | struct cache_head *ch; | 1278 | struct cache_head *ch; |
1283 | struct cache_detail *cd = ((struct handle*)m->private)->cd; | 1279 | struct cache_detail *cd = m->private; |
1284 | |||
1285 | 1280 | ||
1286 | read_lock(&cd->hash_lock); | 1281 | read_lock(&cd->hash_lock); |
1287 | if (!n--) | 1282 | if (!n--) |
@@ -1308,7 +1303,7 @@ static void *c_next(struct seq_file *m, void *p, loff_t *pos) | |||
1308 | { | 1303 | { |
1309 | struct cache_head *ch = p; | 1304 | struct cache_head *ch = p; |
1310 | int hash = (*pos >> 32); | 1305 | int hash = (*pos >> 32); |
1311 | struct cache_detail *cd = ((struct handle*)m->private)->cd; | 1306 | struct cache_detail *cd = m->private; |
1312 | 1307 | ||
1313 | if (p == SEQ_START_TOKEN) | 1308 | if (p == SEQ_START_TOKEN) |
1314 | hash = 0; | 1309 | hash = 0; |
@@ -1334,14 +1329,14 @@ static void *c_next(struct seq_file *m, void *p, loff_t *pos) | |||
1334 | static void c_stop(struct seq_file *m, void *p) | 1329 | static void c_stop(struct seq_file *m, void *p) |
1335 | __releases(cd->hash_lock) | 1330 | __releases(cd->hash_lock) |
1336 | { | 1331 | { |
1337 | struct cache_detail *cd = ((struct handle*)m->private)->cd; | 1332 | struct cache_detail *cd = m->private; |
1338 | read_unlock(&cd->hash_lock); | 1333 | read_unlock(&cd->hash_lock); |
1339 | } | 1334 | } |
1340 | 1335 | ||
1341 | static int c_show(struct seq_file *m, void *p) | 1336 | static int c_show(struct seq_file *m, void *p) |
1342 | { | 1337 | { |
1343 | struct cache_head *cp = p; | 1338 | struct cache_head *cp = p; |
1344 | struct cache_detail *cd = ((struct handle*)m->private)->cd; | 1339 | struct cache_detail *cd = m->private; |
1345 | 1340 | ||
1346 | if (p == SEQ_START_TOKEN) | 1341 | if (p == SEQ_START_TOKEN) |
1347 | return cd->cache_show(m, cd, NULL); | 1342 | return cd->cache_show(m, cd, NULL); |
@@ -1373,24 +1368,27 @@ static const struct seq_operations cache_content_op = { | |||
1373 | static int content_open(struct inode *inode, struct file *file, | 1368 | static int content_open(struct inode *inode, struct file *file, |
1374 | struct cache_detail *cd) | 1369 | struct cache_detail *cd) |
1375 | { | 1370 | { |
1376 | struct handle *han; | 1371 | struct seq_file *seq; |
1372 | int err; | ||
1377 | 1373 | ||
1378 | if (!cd || !try_module_get(cd->owner)) | 1374 | if (!cd || !try_module_get(cd->owner)) |
1379 | return -EACCES; | 1375 | return -EACCES; |
1380 | han = __seq_open_private(file, &cache_content_op, sizeof(*han)); | 1376 | |
1381 | if (han == NULL) { | 1377 | err = seq_open(file, &cache_content_op); |
1378 | if (err) { | ||
1382 | module_put(cd->owner); | 1379 | module_put(cd->owner); |
1383 | return -ENOMEM; | 1380 | return err; |
1384 | } | 1381 | } |
1385 | 1382 | ||
1386 | han->cd = cd; | 1383 | seq = file->private_data; |
1384 | seq->private = cd; | ||
1387 | return 0; | 1385 | return 0; |
1388 | } | 1386 | } |
1389 | 1387 | ||
1390 | static int content_release(struct inode *inode, struct file *file, | 1388 | static int content_release(struct inode *inode, struct file *file, |
1391 | struct cache_detail *cd) | 1389 | struct cache_detail *cd) |
1392 | { | 1390 | { |
1393 | int ret = seq_release_private(inode, file); | 1391 | int ret = seq_release(inode, file); |
1394 | module_put(cd->owner); | 1392 | module_put(cd->owner); |
1395 | return ret; | 1393 | return ret; |
1396 | } | 1394 | } |