Implement ->proc_write_buf() so procfs copies in what is written before it pins the entry. simple_transaction_get() was only used to get a copy of what was written, so look at procfs' copy instead and drop the transaction. A second write to the same file doesn't fail with -EBUSY anymore. Writes larger than PAGE_SIZE - 1 bytes fail with -EINVAL from procfs instead of -EFBIG from simple_transaction_get(), which refused a few bytes less.
Signed-off-by: Christian Brauner (Amutable) <[email protected]> --- fs/lockd/procfs.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/fs/lockd/procfs.c b/fs/lockd/procfs.c index a01f08c8c2f3..47949bec7a09 100644 --- a/fs/lockd/procfs.c +++ b/fs/lockd/procfs.c @@ -18,21 +18,15 @@ * We only allow strings that start with 'Y', 'y', or '1'. */ static ssize_t -nlm_end_grace_write(struct file *file, const char __user *buf, size_t size, - loff_t *pos) +nlm_end_grace_write(struct file *file, char *buf, size_t size, loff_t *pos) { - char *data; struct lockd_net *ln = net_generic(current->nsproxy->net_ns, lockd_net_id); if (size < 1) return -EINVAL; - data = simple_transaction_get(file, buf, size); - if (IS_ERR(data)) - return PTR_ERR(data); - - switch(data[0]) { + switch(buf[0]) { case 'Y': case 'y': case '1': @@ -61,10 +55,9 @@ nlm_end_grace_read(struct file *file, char __user *buf, size_t size, } static const struct proc_ops lockd_end_grace_proc_ops = { - .proc_write = nlm_end_grace_write, + .proc_write_buf = nlm_end_grace_write, .proc_read = nlm_end_grace_read, .proc_lseek = default_llseek, - .proc_release = simple_transaction_release, }; int __init -- 2.53.0
