f_owner.lock and file->pos updates

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linux Kernel Mailing List <linux-kernel@...>
Date: Wednesday, March 7, 2007 - 3:17 pm

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
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
f_owner.lock and file->pos updates, Michael K. Edwards, (Wed Mar 7, 3:17 pm)
Re: f_owner.lock and file-&gt;pos updates, Alan Cox, (Wed Mar 7, 8:48 pm)
Re: f_owner.lock and file-&gt;pos updates, Michael K. Edwards, (Wed Mar 7, 9:50 pm)
Re: f_owner.lock and file-&gt;pos updates, Michael K. Edwards, (Wed Mar 7, 10:12 pm)