Re: [RFC] write(2) semantics wrt return values and current position

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 06, 2015 at 05:02:31PM +0100, Al Viro wrote:

7) commit 3a83b342c87e6d21290de8dc76ec20a67821261d
Author: Joseph Qi <joseph.qi@xxxxxxxxxx>
Date:   Mon Feb 16 16:00:09 2015 -0800

    ocfs2: complete the rest request through buffer io

appears to be very odd.  Look:

                written = generic_file_direct_write(iocb, from, *ppos);
-               if (written < 0) {
+               if (written < 0 || written == count) {
                        ret = written;
                        goto out_dio;
                }
+
+               /*
+                * for completing the rest of the request.
+                */
+               *ppos += written;

ppos here is &iocb->ki_pos.  Now, take a look at the end of
generic_file_direct_write():
        if (written > 0) {
                pos += written;
                iov_iter_advance(from, written);
                if (pos > i_size_read(inode) && !S_ISBLK(inode->i_mode)) {
                        i_size_write(inode, pos);
                        mark_inode_dirty(inode);
                }
                iocb->ki_pos = pos;
        }
out:
        return written;

In other words, after short write done by ->direct_IO(), we end up incrementing
position by *twice* the amount written by it.  And if it's short, but not
empty, we appear to be buggered...

Unless I hear "Al, you idiot, it's doing the right thing, here's what you've
missed: ...", I'm going to take that increment in ocfs2_file_write_iter()
out, and send it to Linus for 4.0 - it's post-3.19 regression.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux