From patchwork Wed Oct 11 20:06:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10000483 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 E1D02603B5 for ; Wed, 11 Oct 2017 20:07:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5F6D28B66 for ; Wed, 11 Oct 2017 20:07:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CACFE28B68; Wed, 11 Oct 2017 20:07:10 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 7F1B428B66 for ; Wed, 11 Oct 2017 20:07:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757963AbdJKUHI (ORCPT ); Wed, 11 Oct 2017 16:07:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:58305 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752580AbdJKUGU (ORCPT ); Wed, 11 Oct 2017 16:06:20 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BBDA2ADCB; Wed, 11 Oct 2017 20:06:15 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 7915B1E35E3; Wed, 11 Oct 2017 22:06:14 +0200 (CEST) From: Jan Kara To: Cc: , , Christoph Hellwig , Dan Williams , Ross Zwisler , Ted Tso , "Darrick J. Wong" , Jan Kara Subject: [PATCH 19/19] xfs: Add support for MAP_SYNC flag Date: Wed, 11 Oct 2017 22:06:03 +0200 Message-Id: <20171011200603.27442-20-jack@suse.cz> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20171011200603.27442-1-jack@suse.cz> References: <20171011200603.27442-1-jack@suse.cz> 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 Now when everything is prepared, add support in xfs to accept MAP_SYNC as an mmap(2) flag. Signed-off-by: Jan Kara --- fs/ext4/file.c | 1 + fs/xfs/xfs_file.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index f013cda84b3d..6b597cc6b29d 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "ext4.h" #include "ext4_jbd2.h" #include "xattr.h" diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index c45f24ffab22..fb135224476d 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -44,6 +44,7 @@ #include #include #include +#include static const struct vm_operations_struct xfs_file_vm_ops; @@ -1142,6 +1143,27 @@ xfs_file_mmap( return 0; } +#define XFS_MAP_SUPPORTED (LEGACY_MAP_MASK | MAP_SYNC) + +static int +xfs_file_mmap_validate( + struct file *filp, + struct vm_area_struct *vma, + unsigned long map_flags) +{ + if (map_flags & ~XFS_MAP_SUPPORTED) + return -EOPNOTSUPP; + + /* + * We don't support synchronous mappings for non-DAX files. At least + * until someone comes with a sensible use case. + */ + if (!IS_DAX(file_inode(filp)) && (map_flags & MAP_SYNC)) + return -EOPNOTSUPP; + + return xfs_file_mmap(filp, vma); +} + const struct file_operations xfs_file_operations = { .llseek = xfs_file_llseek, .read_iter = xfs_file_read_iter, @@ -1153,6 +1175,7 @@ const struct file_operations xfs_file_operations = { .compat_ioctl = xfs_file_compat_ioctl, #endif .mmap = xfs_file_mmap, + .mmap_validate = xfs_file_mmap_validate, .open = xfs_file_open, .release = xfs_file_release, .fsync = xfs_file_fsync,