Patchwork Fix losing locks during fork

login
register
mail settings
Submitter piastry@etersoft.ru
Date April 21, 2010, 6:44 p.m.
Message ID <201004212244.51902.piastry@etersoft.ru>
Download mbox | patch
Permalink /patch/50670/
State New
Headers show

Comments

piastry@etersoft.ru - April 21, 2010, 6:44 p.m.
Yes, sorry for this mistake. The right variant of the patch is in attachment.

В сообщении от 21 апреля 2010 06:58:26 вы написали:
> Could you fix the tabs converted to spaces accidently in your patch and
> resend? (which causes a merge problem too I think - with current
> cifs-2.6.git tree at least).
> 
> On Wed, Apr 7, 2010 at 1:28 AM, Pavel Shilovsky <piastry@etersoft.ru> wrote:
> > В сообщении от 7 апреля 2010 00:34:32 вы написали:
> >> Is the equivalent fix in the smb2 code?
> >> 
> >> On Tue, Apr 6, 2010 at 1:41 PM, Pavel Shilovsky <piastry@etersoft.ru> wrote:
> >> > Resend patch with "Reviewed-by: Jeff Layton <jlayton@samba.org>" in
> >> > attachment.
> >> > 
> >> > --
> >> > Best regards,
> >> > Pavel Shilovsky.
> > 
> > Yes, this fix exists in smb2 code.
> > 
> > P. S. Sorry, I have just noticed your email - after sending you a
> > question from gmail.com. --
> > Best regards,
> > Pavel Shilovsky.

--
Best regards,
Pavel Shilovsky.
Steve French - April 21, 2010, 7:44 p.m.
Merged.

2010/4/21 Pavel Shilovsky <piastry@etersoft.ru>:
> Yes, sorry for this mistake. The right variant of the patch is in attachment.


>> On Wed, Apr 7, 2010 at 1:28 AM, Pavel Shilovsky <piastry@etersoft.ru> wrote:
>> > В сообщении от 7 апреля 2010 00:34:32 вы написали:
>> >> Is the equivalent fix in the smb2 code?
>> >>
>> >> On Tue, Apr 6, 2010 at 1:41 PM, Pavel Shilovsky <piastry@etersoft.ru> wrote:
>> >> > Resend patch with "Reviewed-by: Jeff Layton <jlayton@samba.org>" in
>> >> > attachment.

Patch

From: Pavel Shilovsky <piastryyy@gmail.com>

[CIFS] Fix losing locks during fork()

When process does fork() private_data of files with lock list stays the same
for file descriptors of the parent and of the child. While finishing the child closes
files and deletes locks from the list even if unlocking fails. When the child process
finishes the parent doesn't have lock in lock list and can't unlock previously before
fork() locked region after the child process finished.

This patch provides behaviour to save locks in lock list if unlocking fails.

Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com>
Reviewed-by: Jeff Layton <jlayton@samba.org>
---
 fs/cifs/file.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 9b11a8f..1f00d43 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -923,9 +923,10 @@  int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
 							1, 0, li->type, false);
 					if (stored_rc)
 						rc = stored_rc;
-
-					list_del(&li->llist);
-					kfree(li);
+					else {
+						list_del(&li->llist);
+						kfree(li);
+					}
 				}
 			}
 			mutex_unlock(&fid->lock_mutex);
-- 
1.6.6.1