summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r--net/sunrpc/cache.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 6f1528f271ee..a349094f6fb7 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -373,7 +373,7 @@ void sunrpc_init_cache_detail(struct cache_detail *cd)
373 spin_lock(&cache_list_lock); 373 spin_lock(&cache_list_lock);
374 cd->nextcheck = 0; 374 cd->nextcheck = 0;
375 cd->entries = 0; 375 cd->entries = 0;
376 atomic_set(&cd->readers, 0); 376 atomic_set(&cd->writers, 0);
377 cd->last_close = 0; 377 cd->last_close = 0;
378 cd->last_warn = -1; 378 cd->last_warn = -1;
379 list_add(&cd->others, &cache_list); 379 list_add(&cd->others, &cache_list);
@@ -1029,11 +1029,13 @@ static int cache_open(struct inode *inode, struct file *filp,
1029 } 1029 }
1030 rp->offset = 0; 1030 rp->offset = 0;
1031 rp->q.reader = 1; 1031 rp->q.reader = 1;
1032 atomic_inc(&cd->readers); 1032
1033 spin_lock(&queue_lock); 1033 spin_lock(&queue_lock);
1034 list_add(&rp->q.list, &cd->queue); 1034 list_add(&rp->q.list, &cd->queue);
1035 spin_unlock(&queue_lock); 1035 spin_unlock(&queue_lock);
1036 } 1036 }
1037 if (filp->f_mode & FMODE_WRITE)
1038 atomic_inc(&cd->writers);
1037 filp->private_data = rp; 1039 filp->private_data = rp;
1038 return 0; 1040 return 0;
1039} 1041}
@@ -1062,8 +1064,10 @@ static int cache_release(struct inode *inode, struct file *filp,
1062 filp->private_data = NULL; 1064 filp->private_data = NULL;
1063 kfree(rp); 1065 kfree(rp);
1064 1066
1067 }
1068 if (filp->f_mode & FMODE_WRITE) {
1069 atomic_dec(&cd->writers);
1065 cd->last_close = seconds_since_boot(); 1070 cd->last_close = seconds_since_boot();
1066 atomic_dec(&cd->readers);
1067 } 1071 }
1068 module_put(cd->owner); 1072 module_put(cd->owner);
1069 return 0; 1073 return 0;
@@ -1171,7 +1175,7 @@ static void warn_no_listener(struct cache_detail *detail)
1171 1175
1172static bool cache_listeners_exist(struct cache_detail *detail) 1176static bool cache_listeners_exist(struct cache_detail *detail)
1173{ 1177{
1174 if (atomic_read(&detail->readers)) 1178 if (atomic_read(&detail->writers))
1175 return true; 1179 return true;
1176 if (detail->last_close == 0) 1180 if (detail->last_close == 0)
1177 /* This cache was never opened */ 1181 /* This cache was never opened */
@@ -1520,6 +1524,9 @@ static ssize_t write_flush(struct file *file, const char __user *buf,
1520 cd->nextcheck = now; 1524 cd->nextcheck = now;
1521 cache_flush(); 1525 cache_flush();
1522 1526
1527 if (cd->flush)
1528 cd->flush();
1529
1523 *ppos += count; 1530 *ppos += count;
1524 return count; 1531 return count;
1525} 1532}