mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* f_owner.lock and file->pos updates
@ 2007-03-07 19:17 Michael K. Edwards
  2007-03-08  0:48 ` Alan Cox
  0 siblings, 1 reply; 4+ messages in thread
From: Michael K. Edwards @ 2007-03-07 19:17 UTC (permalink / raw)
  To: Linux Kernel Mailing List

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-03-08  2:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-07 19:17 f_owner.lock and file->pos updates Michael K. Edwards
2007-03-08  0:48 ` Alan Cox
2007-03-08  1:50   ` Michael K. Edwards
2007-03-08  2:12     ` Michael K. Edwards

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®