Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752712AbbDEVyv (ORCPT ); Sun, 5 Apr 2015 17:54:51 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:40722 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752530AbbDEVyt (ORCPT ); Sun, 5 Apr 2015 17:54:49 -0400 Date: Sun, 5 Apr 2015 22:54:46 +0100 From: Al Viro To: Dmitry Monakhov Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 02/16] vfs: check kiocb->ki_flags instead filp->fl_flags Message-ID: <20150405215446.GK889@ZenIV.linux.org.uk> References: <1428174805-853-1-git-send-email-dmonakhov@openvz.org> <1428174805-853-3-git-send-email-dmonakhov@openvz.org> <20150404213621.GH889@ZenIV.linux.org.uk> <871tjy96rp.fsf@openvz.org> <20150405181145.GJ889@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150405181145.GJ889@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2025 Lines: 45 On Sun, Apr 05, 2015 at 07:11:45PM +0100, Al Viro wrote: > On Sun, Apr 05, 2015 at 02:03:22PM +0300, Dmitry Monakhov wrote: > > > I'm not sure I have get your point about ocfs2 because it does > > iov_iter_truncate() right after generic_write_checks() > > This > ret = ocfs2_prepare_inode_for_write(file, ppos, count, appending, > &can_do_direct, &has_refcount); > being done before generic_write_checks(). It actually duplicates some > parts of generic_write_checks() inside (O_APPEND-related, and AFAICS > they _are_ triggered twice that way). XFS seems to be buggered as well: /* DIO must be aligned to device logical sector size */ if ((pos | count) & target->bt_logical_sectormask) return -EINVAL; /* "unaligned" here means not aligned to a filesystem block */ if ((pos & mp->m_blockmask) || ((pos + count) & mp->m_blockmask)) unaligned_io = 1; ... ret = xfs_file_aio_write_checks(file, &pos, &count, &iolock); now, play with rlimit() and suddenly the alignment checks above have nothing to do with what'll actually happen after that sucker - it's calling generic_write_checks(), so... Incidentally, we want the result of alignment check to decide how to take the lock that protects the file size, so simply lifting O_APPEND treatment above those won't do. I suspect that in case of lock taken shared we need to redo alignment checks and treat "it became unaligned" as "unlock and redo it with lock taken exclusive". BTW, xfs_break_layouts() having dropped and regained lock would invalidate the O_APPEND treatment in generic_write_checks() just prior (both in xfs_file_aio_write_checks())... Al "really not fond of xfs_rw_ilock()" Viro... -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/