From patchwork Tue Mar 29 17:37:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 8689201 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9F9E8C0553 for ; Tue, 29 Mar 2016 17:38:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BEAE82034B for ; Tue, 29 Mar 2016 17:38:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1F832035D for ; Tue, 29 Mar 2016 17:38:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757897AbcC2Rh4 (ORCPT ); Tue, 29 Mar 2016 13:37:56 -0400 Received: from casper.infradead.org ([85.118.1.10]:55312 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757887AbcC2Rhp (ORCPT ); Tue, 29 Mar 2016 13:37:45 -0400 Received: from [83.175.99.196] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.85 #2 (Red Hat Linux)) id 1akxaK-0002IR-0R; Tue, 29 Mar 2016 17:37:44 +0000 From: Christoph Hellwig To: viro@ZenIV.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org Subject: [PATCH 09/10] fs: add RWF_DSYNC aand RWF_SYNC Date: Tue, 29 Mar 2016 19:37:33 +0200 Message-Id: <1459273054-13478-10-git-send-email-hch@lst.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459273054-13478-1-git-send-email-hch@lst.de> References: <1459273054-13478-1-git-send-email-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is the per-I/O equivalent of O_DSYNC and O_SYNC, and very useful for all kinds of file servers and storage targets. Signed-off-by: Christoph Hellwig --- fs/read_write.c | 6 +++++- include/uapi/linux/fs.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/read_write.c b/fs/read_write.c index cf377cf..3729d8d 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -698,12 +698,16 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter, struct kiocb kiocb; ssize_t ret; - if (flags & ~RWF_HIPRI) + if (flags & ~(RWF_HIPRI | RWF_DSYNC | RWF_SYNC)) return -EOPNOTSUPP; init_sync_kiocb(&kiocb, filp); if (flags & RWF_HIPRI) kiocb.ki_flags |= IOCB_HIPRI; + if (flags & RWF_DSYNC) + kiocb.ki_flags |= IOCB_DSYNC; + if (flags & RWF_SYNC) + kiocb.ki_flags |= (IOCB_DSYNC | IOCB_SYNC); kiocb.ki_pos = *ppos; ret = fn(&kiocb, iter); diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index a079d50..7f067fe 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -324,5 +324,7 @@ struct fscrypt_policy { /* flags for preadv2/pwritev2: */ #define RWF_HIPRI 0x00000001 /* high priority request, poll if possible */ +#define RWF_DSYNC 0x00000002 /* per-IO O_DSYNC */ +#define RWF_SYNC 0x00000002 /* per-IO O_SYNC */ #endif /* _UAPI_LINUX_FS_H */