Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fuse: change interrupt requests allocation algorithm

Using of two unconnected IDs req->in.h.unique and req->intr_unique does not
allow to link requests to a hash table. We need can't use none of them as a
key to calculate hash.

This patch changes the algorithm of allocation of IDs for a request. Plain
requests obtain even ID, while interrupt requests are encoded in the low
bit. So, in next patches we will be able to use the rest of ID bits to
calculate hash, and the hash will be the same for plain and interrupt
requests.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>

authored by

Kirill Tkhai and committed by
Miklos Szeredi
c59fd85e 63825b4e

+7 -2
+7 -2
fs/fuse/dev.c
··· 25 25 MODULE_ALIAS_MISCDEV(FUSE_MINOR); 26 26 MODULE_ALIAS("devname:fuse"); 27 27 28 + /* Ordinary requests have even IDs, while interrupts IDs are odd */ 29 + #define FUSE_INT_REQ_BIT (1ULL << 0) 30 + #define FUSE_REQ_ID_STEP (1ULL << 1) 31 + 28 32 static struct kmem_cache *fuse_req_cachep; 29 33 30 34 static struct fuse_dev *fuse_get_dev(struct file *file) ··· 323 319 324 320 static u64 fuse_get_unique(struct fuse_iqueue *fiq) 325 321 { 326 - return ++fiq->reqctr; 322 + fiq->reqctr += FUSE_REQ_ID_STEP; 323 + return fiq->reqctr; 327 324 } 328 325 329 326 static void queue_request(struct fuse_iqueue *fiq, struct fuse_req *req) ··· 1095 1090 int err; 1096 1091 1097 1092 list_del_init(&req->intr_entry); 1098 - req->intr_unique = fuse_get_unique(fiq); 1093 + req->intr_unique = (req->in.h.unique | FUSE_INT_REQ_BIT); 1099 1094 memset(&ih, 0, sizeof(ih)); 1100 1095 memset(&arg, 0, sizeof(arg)); 1101 1096 ih.len = reqsize;