aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2015-08-25 13:51:44 -0400
committerDavid Teigland <teigland@redhat.com>2015-08-25 15:41:50 -0400
commitb96f465035f9fae83c1d8de3e80eecfe6877608c (patch)
tree75659c1ba50859bf0b5537972f94f439f2d0867e
parent18df8a87badac0ab05679df9bd44b5033e30d97c (diff)
dlm: fix lvb copy for user locks
For a userland lock request, the previous and current lock modes are used to decide when the lvb should be copied back to the user. The wrong previous value was used, so that it always matched the current value. This caused the lvb to be copied back to the user in the wrong cases. Signed-off-by: David Teigland <teigland@redhat.com>
-rw-r--r--fs/dlm/user.c7
-rw-r--r--include/uapi/linux/dlm_device.h2
2 files changed, 5 insertions, 4 deletions
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index fb85f32e9eca..35960502ec8d 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -785,6 +785,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
785 DECLARE_WAITQUEUE(wait, current); 785 DECLARE_WAITQUEUE(wait, current);
786 struct dlm_callback cb; 786 struct dlm_callback cb;
787 int rv, resid, copy_lvb = 0; 787 int rv, resid, copy_lvb = 0;
788 int old_mode, new_mode;
788 789
789 if (count == sizeof(struct dlm_device_version)) { 790 if (count == sizeof(struct dlm_device_version)) {
790 rv = copy_version_to_user(buf, count); 791 rv = copy_version_to_user(buf, count);
@@ -841,6 +842,9 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
841 842
842 lkb = list_entry(proc->asts.next, struct dlm_lkb, lkb_cb_list); 843 lkb = list_entry(proc->asts.next, struct dlm_lkb, lkb_cb_list);
843 844
845 /* rem_lkb_callback sets a new lkb_last_cast */
846 old_mode = lkb->lkb_last_cast.mode;
847
844 rv = dlm_rem_lkb_callback(lkb->lkb_resource->res_ls, lkb, &cb, &resid); 848 rv = dlm_rem_lkb_callback(lkb->lkb_resource->res_ls, lkb, &cb, &resid);
845 if (rv < 0) { 849 if (rv < 0) {
846 /* this shouldn't happen; lkb should have been removed from 850 /* this shouldn't happen; lkb should have been removed from
@@ -864,9 +868,6 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
864 } 868 }
865 869
866 if (cb.flags & DLM_CB_CAST) { 870 if (cb.flags & DLM_CB_CAST) {
867 int old_mode, new_mode;
868
869 old_mode = lkb->lkb_last_cast.mode;
870 new_mode = cb.mode; 871 new_mode = cb.mode;
871 872
872 if (!cb.sb_status && lkb->lkb_lksb->sb_lvbptr && 873 if (!cb.sb_status && lkb->lkb_lksb->sb_lvbptr &&
diff --git a/include/uapi/linux/dlm_device.h b/include/uapi/linux/dlm_device.h
index 3060783c4191..df56c8ff0769 100644
--- a/include/uapi/linux/dlm_device.h
+++ b/include/uapi/linux/dlm_device.h
@@ -26,7 +26,7 @@
26/* Version of the device interface */ 26/* Version of the device interface */
27#define DLM_DEVICE_VERSION_MAJOR 6 27#define DLM_DEVICE_VERSION_MAJOR 6
28#define DLM_DEVICE_VERSION_MINOR 0 28#define DLM_DEVICE_VERSION_MINOR 0
29#define DLM_DEVICE_VERSION_PATCH 1 29#define DLM_DEVICE_VERSION_PATCH 2
30 30
31/* struct passed to the lock write */ 31/* struct passed to the lock write */
32struct dlm_lock_params { 32struct dlm_lock_params {