From patchwork Tue Feb 28 14:57:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9595925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 71D9B601D7 for ; Tue, 28 Feb 2017 14:58:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6732F28497 for ; Tue, 28 Feb 2017 14:58:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C291284FF; Tue, 28 Feb 2017 14:58:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 150AB28497 for ; Tue, 28 Feb 2017 14:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752481AbdB1O62 (ORCPT ); Tue, 28 Feb 2017 09:58:28 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:44672 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107AbdB1O6E (ORCPT ); Tue, 28 Feb 2017 09:58:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HnweiSVtjz0RmEiKlG0+DTGj4THEOI1YyNUb/KCH4jc=; b=Tb3GHN1z4wfH+/0e7HpYBLlTA KomQvLtk0tQCs6wp/Xfg7Te5WxLrxk31ZWcuU0dpbt5kFB6Ba8dGpZmWEsICOmYZCmeH9EIukKPDi bqVqJy+NBDD/z7zel5NFyCn6M2talXhjl1d8skW4zYqSF3Q9PxDnjdbLwMpDjrlNQ+eGJWqPLwe+6 +oUYaf7LQE6Uodv8VlRwwkX0M7y3IQst/j02Mnb8h9+ZS9cB1b6PV3JuF5WiXDR5so+JH6+Dy/zaM RlF8FboVy/4u4e6sKp4j2r8pNWjh+zE0J4j/jfbTLIT1sATtEI3rjKD2YxqCYcoeFM2R0e1yFCPiO ZkHQLUsGw==; Received: from [8.25.222.2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cijDe-0006Rz-NM; Tue, 28 Feb 2017 14:57:38 +0000 From: Christoph Hellwig To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 08/12] xfs: implement the F_IOINFO fcntl Date: Tue, 28 Feb 2017 06:57:33 -0800 Message-Id: <20170228145737.19016-9-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170228145737.19016-1-hch@lst.de> References: <20170228145737.19016-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_file.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index a7d8324b59c5..4d955b3266df 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -898,6 +898,39 @@ xfs_file_dedupe_range( return len; } +static uint16_t +xfs_dio_alignment(struct file *file) +{ + struct xfs_inode *ip = XFS_I(file_inode(file)); + struct xfs_mount *mp = ip->i_mount; + + if (file->f_flags & O_ATOMIC) + return mp->m_sb.sb_blocksize; + else if (XFS_IS_REALTIME_INODE(ip)) + return mp->m_rtdev_targp->bt_logical_sectorsize; + else + return mp->m_ddev_targp->bt_logical_sectorsize; +} + +static int +xfs_file_ioinfo( + struct file *file, + struct fcntl_ioinfo *fio) +{ + if (file->f_flags & O_DIRECT) + fio->fio_alignment = xfs_dio_alignment(file); + + if (file->f_flags & O_ATOMIC) { + fio->fio_flags = FIO_FL_ATOMIC_OSYNC | FIO_FL_ATOMIC_FSYNC; + fio->fio_max_atomic = INT_MAX; + if (fio->fio_alignment) + fio->fio_max_atomic &= ~(fio->fio_alignment - 1); + } + + + return 0; +}; + STATIC int xfs_file_open( struct inode *inode, @@ -1556,6 +1589,7 @@ const struct file_operations xfs_file_operations = { .fallocate = xfs_file_fallocate, .clone_file_range = xfs_file_clone_range, .dedupe_file_range = xfs_file_dedupe_range, + .ioinfo = xfs_file_ioinfo, }; const struct file_operations xfs_dir_file_operations = {