From patchwork Tue Feb 28 14:57:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9595909 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 358C260574 for ; Tue, 28 Feb 2017 14:58:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AE2428497 for ; Tue, 28 Feb 2017 14:58:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FFB328516; Tue, 28 Feb 2017 14:58:31 +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 BECF9284EF for ; Tue, 28 Feb 2017 14:58:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751986AbdB1O62 (ORCPT ); Tue, 28 Feb 2017 09:58:28 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:49757 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752093AbdB1O6E (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=3S35joFEPVds0A58t3M1lfM/FiVt9+VeCILMbGKS8sg=; b=dceVV1us6Z1bTsfoC1H7GZ4fa BE/zarzl5RGfm1yEtaN6FIBvZM5saJytiS6p4D+sjKOBEKag4fNeP9RsTjfXwvqX4nPcb33XQXMJf uIgPP9M2TP7m3eewwKrOYf80oYQoNocSdKTt+EuLEzHd6vPld/uLnPuvtEq8m/pd/tl/c5F2ztY4a kOZMMlKVRF8pcBTw0iXoErPjA+CEzKsfa8OSrBW1Sdbkxh2ErVj52OOLTfok9B33fGMRnFwfY+Ef7 1Tq28X9LOD5TjsvOlkOHdVZdgYM7qAU0MCQUNKA3VOjcaFjccz8l64gkJIClmSvx7icfenbWhlbk+ ct3EavIqQ==; Received: from [8.25.222.2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cijDe-0006Ro-B3; 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 05/12] fs: add a F_IOINFO fcntl Date: Tue, 28 Feb 2017 06:57:30 -0800 Message-Id: <20170228145737.19016-6-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 This fcntl can be used to query I/O parameters for the given file descriptor. Initially it is used for the I/O alignment and atomic write parameters. Signed-off-by: Christoph Hellwig --- fs/fcntl.c | 18 ++++++++++++++++++ include/linux/fs.h | 1 + include/uapi/linux/fcntl.h | 16 ++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/fs/fcntl.c b/fs/fcntl.c index ca5d228be7ea..248fb4cc66a6 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -241,6 +241,21 @@ static int f_getowner_uids(struct file *filp, unsigned long arg) } #endif +static int fcntl_ioinfo(struct file *file, void __user *argp) +{ + struct fcntl_ioinfo fio = { 0, }; + + if (file->f_op->ioinfo) { + int ret = file->f_op->ioinfo(file, &fio); + if (ret) + return ret; + } + + if (copy_to_user(argp, &fio, sizeof(fio))) + return -EFAULT; + return 0; +} + static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, struct file *filp) { @@ -335,6 +350,9 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, case F_GET_SEALS: err = shmem_fcntl(filp, cmd, arg); break; + case F_IOINFO: + err = fcntl_ioinfo(filp, (void __user *)arg); + break; default: break; } diff --git a/include/linux/fs.h b/include/linux/fs.h index 2ba074328894..33b08a8c2bc3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1680,6 +1680,7 @@ struct file_operations { u64); ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, u64); + int (*ioinfo)(struct file *, struct fcntl_ioinfo *); }; struct inode_operations { diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index beed138bd359..6b0aaba7c623 100644 --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h @@ -42,6 +42,22 @@ #define F_SEAL_WRITE 0x0008 /* prevent writes */ /* (1U << 31) is reserved for signed error codes */ + +#define F_IOINFO (F_LINUX_SPECIFIC_BASE + 11) + +struct fcntl_ioinfo { + __u16 fio_flags; /* FIO_FL_* */ + __u16 fio_alignment; /* required I/O alignment on disk */ + __u32 __reserved1; /* must be zero */ + __u64 fio_max_atomic; /* max size for atomic writes */ + __u64 __reserved2[14];/* must be zero */ +}; + +/* supports atomic writes using O_(D)SYNC */ +#define FIO_FL_ATOMIC_OSYNC (1 << 0) +/* supports atomic writes committed using fsync/fdatasync/msync */ +#define FIO_FL_ATOMIC_FSYNC (1 << 1) + /* * Types of directory notifications that may be requested. */