]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/9p-locks-add-mount-option-for-lock-retry-interval.patch
autosel patches for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / 9p-locks-add-mount-option-for-lock-retry-interval.patch
1 From 9eb0f818d6a3eb7d236730aa441591d79b4a9c3a Mon Sep 17 00:00:00 2001
2 From: Dinu-Razvan Chis-Serban <justcsdr@gmail.com>
3 Date: Wed, 5 Sep 2018 16:44:12 +0900
4 Subject: 9p locks: add mount option for lock retry interval
5
6 [ Upstream commit 5e172f75e51e3de1b4274146d9b990f803cb5c2a ]
7
8 The default P9_LOCK_TIMEOUT can be too long for some users exporting
9 a local file system to a guest VM (30s), make this configurable at
10 mount time.
11
12 Link: http://lkml.kernel.org/r/1536295827-3181-1-git-send-email-asmadeus@codewreck.org
13 Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195727
14 Signed-off-by: Dinu-Razvan Chis-Serban <justcsdr@gmail.com>
15 Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
16 Signed-off-by: Sasha Levin <sashal@kernel.org>
17 ---
18 fs/9p/v9fs.c | 21 +++++++++++++++++++++
19 fs/9p/v9fs.h | 1 +
20 fs/9p/vfs_file.c | 6 +++++-
21 3 files changed, 27 insertions(+), 1 deletion(-)
22
23 diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
24 index 8fb89ddc6cc7..c52f10efdc9c 100644
25 --- a/fs/9p/v9fs.c
26 +++ b/fs/9p/v9fs.c
27 @@ -61,6 +61,8 @@ enum {
28 Opt_cache_loose, Opt_fscache, Opt_mmap,
29 /* Access options */
30 Opt_access, Opt_posixacl,
31 + /* Lock timeout option */
32 + Opt_locktimeout,
33 /* Error token */
34 Opt_err
35 };
36 @@ -80,6 +82,7 @@ static const match_table_t tokens = {
37 {Opt_cachetag, "cachetag=%s"},
38 {Opt_access, "access=%s"},
39 {Opt_posixacl, "posixacl"},
40 + {Opt_locktimeout, "locktimeout=%u"},
41 {Opt_err, NULL}
42 };
43
44 @@ -187,6 +190,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
45 #ifdef CONFIG_9P_FSCACHE
46 v9ses->cachetag = NULL;
47 #endif
48 + v9ses->session_lock_timeout = P9_LOCK_TIMEOUT;
49
50 if (!opts)
51 return 0;
52 @@ -360,6 +364,23 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
53 #endif
54 break;
55
56 + case Opt_locktimeout:
57 + r = match_int(&args[0], &option);
58 + if (r < 0) {
59 + p9_debug(P9_DEBUG_ERROR,
60 + "integer field, but no integer?\n");
61 + ret = r;
62 + continue;
63 + }
64 + if (option < 1) {
65 + p9_debug(P9_DEBUG_ERROR,
66 + "locktimeout must be a greater than zero integer.\n");
67 + ret = -EINVAL;
68 + continue;
69 + }
70 + v9ses->session_lock_timeout = (long)option * HZ;
71 + break;
72 +
73 default:
74 continue;
75 }
76 diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
77 index 982e017acadb..129e5243a6bf 100644
78 --- a/fs/9p/v9fs.h
79 +++ b/fs/9p/v9fs.h
80 @@ -116,6 +116,7 @@ struct v9fs_session_info {
81 struct p9_client *clnt; /* 9p client */
82 struct list_head slist; /* list of sessions registered with v9fs */
83 struct rw_semaphore rename_sem;
84 + long session_lock_timeout; /* retry interval for blocking locks */
85 };
86
87 /* cache_validity flags */
88 diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
89 index af8cac975a74..89e69904976a 100644
90 --- a/fs/9p/vfs_file.c
91 +++ b/fs/9p/vfs_file.c
92 @@ -154,6 +154,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
93 uint8_t status = P9_LOCK_ERROR;
94 int res = 0;
95 unsigned char fl_type;
96 + struct v9fs_session_info *v9ses;
97
98 fid = filp->private_data;
99 BUG_ON(fid == NULL);
100 @@ -189,6 +190,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
101 if (IS_SETLKW(cmd))
102 flock.flags = P9_LOCK_FLAGS_BLOCK;
103
104 + v9ses = v9fs_inode2v9ses(file_inode(filp));
105 +
106 /*
107 * if its a blocked request and we get P9_LOCK_BLOCKED as the status
108 * for lock request, keep on trying
109 @@ -202,7 +205,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
110 break;
111 if (status == P9_LOCK_BLOCKED && !IS_SETLKW(cmd))
112 break;
113 - if (schedule_timeout_interruptible(P9_LOCK_TIMEOUT) != 0)
114 + if (schedule_timeout_interruptible(v9ses->session_lock_timeout)
115 + != 0)
116 break;
117 /*
118 * p9_client_lock_dotl overwrites flock.client_id with the
119 --
120 2.19.1
121