From: "Michael K. Edwards" <medwards.linux@gmail.com>
To: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: f_owner.lock and file->pos updates
Date: Wed, 7 Mar 2007 11:17:36 -0800 [thread overview]
Message-ID: <f2b55d220703071117n474f02f7rcc630f0415530aed@mail.gmail.com> (raw)
Suppose I want to create an atomic llseek+writev operation. Is this
more or less sufficient:
ssize_t ret = -EBADF;
file = fget_light(fd, &fput_needed);
if (file) {
if (unlikely(origin > 2)) {
ret = -EINVAL;
} else {
write_lock_irq(&file->f_owner.lock);
pos = vfs_llseek(file, ((loff_t) offset_high <<
32) | offset_low, origin);
ret = (ssize_t)pos;
if (likely(ret >= 0)) {
ret = vfs_writev(file, vec, vlen, &pos);
file_pos_write(file, pos);
}
write_unlock_irq(&file->f_owner.lock);
}
fput_light(file, fput_needed);
}
Or is this the wrong sort of lock to be using to protect against
having file->pos altered by another thread executing through the same
code?
Cheers,
- Michael
next reply other threads:[~2007-03-07 19:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-07 19:17 Michael K. Edwards [this message]
2007-03-08 0:48 ` Alan Cox
2007-03-08 1:50 ` Michael K. Edwards
2007-03-08 2:12 ` Michael K. Edwards
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=f2b55d220703071117n474f02f7rcc630f0415530aed@mail.gmail.com \
--to=medwards.linux@gmail.com \
--cc=linux-kernel@vger.kernel.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®