From: Petr Vandrovec <vandrove@vc.cvut.cz>
To: willy@debian.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Make {posix,flock}_lock_file interface simpler
Date: Wed, 20 Nov 2002 20:35:19 +0100 [thread overview]
Message-ID: <20021120193519.GB25126@vana> (raw)
Hi Willy,
some months ago, after your fs/locks.c cleanup, and after
troubles we had with getting tests for non-blocking vs. blocking
calls correct, I wrote following patch. If you are still
interested in cleaning up fs/locks.c, can you review it, and
either dump to the floor, or send to Linus?
With old version, we do wait_event_interruptible()
when lock function returned -EAGAIN and we did blocking call.
Patch below changes locking code to return -EAGAIN if
wait_event_interruptible() should not called, and -ERESTARTSYS
if wait_event_interruptible() should be called (that is,
locking code called locks_insert_block()). So now calling
rule is simple: if you got -ERESTARTSYS, you must do
wait_event_interruptible, otherwise you have error code to
return to userspace.
I choosed ERESTARTSYS just arbitrary: it was not used by
currentl locking code, it must not be returned to userspace,
and it already exists.
Thanks,
Petr Vandrovec
vandrove@vc.cvut.cz
diff -urdN linux/fs/locks.c linux/fs/locks.c
--- linux/fs/locks.c 2002-11-20 18:33:14.000000000 +0000
+++ linux/fs/locks.c 2002-11-20 18:42:01.000000000 +0000
@@ -678,7 +678,7 @@
for (;;) {
error = posix_lock_file(filp, &fl);
- if (error != -EAGAIN)
+ if (error != -ERESTARTSYS)
break;
error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
if (!error) {
@@ -749,6 +749,7 @@
error = -EAGAIN;
if (new_fl->fl_flags & FL_SLEEP) {
locks_insert_block(fl, new_fl);
+ error = -ERESTARTSYS;
}
goto out;
}
@@ -812,7 +813,7 @@
error = -EDEADLK;
if (posix_locks_deadlock(request, fl))
goto out;
- error = -EAGAIN;
+ error = -ERESTARTSYS;
locks_insert_block(fl, request);
goto out;
}
@@ -1295,7 +1296,7 @@
for (;;) {
error = flock_lock_file(filp, lock);
- if ((error != -EAGAIN) || (cmd & LOCK_NB))
+ if (error != -ERESTARTSYS)
break;
error = wait_event_interruptible(lock->fl_wait, !lock->fl_next);
if (!error)
@@ -1453,7 +1454,7 @@
for (;;) {
error = posix_lock_file(filp, file_lock);
- if ((error != -EAGAIN) || (cmd == F_SETLK))
+ if (error != -ERESTARTSYS)
break;
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
@@ -1593,7 +1594,7 @@
for (;;) {
error = posix_lock_file(filp, file_lock);
- if ((error != -EAGAIN) || (cmd == F_SETLK64))
+ if (error != -ERESTARTSYS)
break;
error = wait_event_interruptible(file_lock->fl_wait,
!file_lock->fl_next);
reply other threads:[~2002-11-20 19:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021120193519.GB25126@vana \
--to=vandrove@vc.cvut.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®