]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
fuse: add spinlock to protect fc reqctr
authorAshish Samant <ashish.samant@oracle.com>
Wed, 15 Apr 2015 17:44:46 +0000 (10:44 -0700)
committerSantosh Shilimkar <santosh.shilimkar@oracle.com>
Mon, 29 Jun 2015 15:31:24 +0000 (08:31 -0700)
fc->lock protects other members along with sequence counter. Since the
change introduced by next few patches increases parallelism, it increases
contention on fc->lock. Having a new seq_lock spinlock to protect unique
sequence counter will reduce contention and also makes code simpler.

Signed-off-by: Ashish Samant <ashish.samant@oracle.com>
Reviewed-by: Srinivas Eeda <srinivas.eeda@oracle.com>
fs/fuse/dev.c
fs/fuse/fuse_i.h
fs/fuse/inode.c

index afe409e4bd3c1caa3d1843cb46ce26bdb27b0dc4..7de45eaa38a86f9b82478baefb2c0279480bc55b 100644 (file)
@@ -337,12 +337,20 @@ static unsigned len_args(unsigned numargs, struct fuse_arg *args)
 
 static u64 fuse_get_unique(struct fuse_conn *fc)
 {
+       u64 ctr;
+
+       /** Using a separate seq_lock will reduce contention for fc->lock
+        * and make the code cleaner.
+        */
+       spin_lock(&fc->seq_lock);
        fc->reqctr++;
        /* zero is special */
        if (fc->reqctr == 0)
                fc->reqctr = 1;
+       ctr = fc->reqctr;
+       spin_unlock(&fc->seq_lock);
 
-       return fc->reqctr;
+       return ctr;
 }
 
 static void queue_request(struct fuse_node *fn, struct fuse_req *req)
index adbca4ff267d840f6bb19cde0b5f094a63f98b75..bb6df6ab90e48738b885fcdb0434579dd9820720 100644 (file)
@@ -498,6 +498,9 @@ struct fuse_conn {
        /** The next unique request id */
        u64 reqctr;
 
+       /** Lock for protecting access to the reqctr */
+       spinlock_t seq_lock;
+
        /** Connection failed (version mismatch).  Cannot race with
            setting other bitfields since it is only set once in INIT
            reply, before any other request, and never cleared */
index 9c54b1f755024434cb61a61d7834fd988b8f26e5..86c97b0637ab952709410290887a31ddcf56d894 100644 (file)
@@ -574,6 +574,7 @@ int fuse_conn_init(struct fuse_conn *fc)
 
        memset(fc, 0, sizeof(*fc));
        spin_lock_init(&fc->lock);
+       spin_lock_init(&fc->seq_lock);
        init_rwsem(&fc->killsb);
        atomic_set(&fc->count, 1);
        init_waitqueue_head(&fc->reserved_req_waitq);