From patchwork Thu Mar 3 19:31:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Peterson X-Patchwork-Id: 8495721 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4D3959F38C for ; Thu, 3 Mar 2016 19:32:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 716512012E for ; Thu, 3 Mar 2016 19:32:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86CB92037C for ; Thu, 3 Mar 2016 19:32:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754659AbcCCTb6 (ORCPT ); Thu, 3 Mar 2016 14:31:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41111 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751633AbcCCTb5 (ORCPT ); Thu, 3 Mar 2016 14:31:57 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 491EC6436E; Thu, 3 Mar 2016 19:31:57 +0000 (UTC) Received: from loki.redhat.com (ovpn-113-172.phx2.redhat.com [10.3.113.172]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u23JVtmI007287; Thu, 3 Mar 2016 14:31:56 -0500 From: Bob Peterson To: Cc: Jan Kara , Al Viro , Dave Chinner Subject: [vfs PATCH v2 1/4] VFS: move iomap infrastructure from exportfs.h, add iomap to aops Date: Thu, 3 Mar 2016 14:31:52 -0500 Message-Id: <1457033515-7521-2-git-send-email-rpeterso@redhat.com> In-Reply-To: <1457033515-7521-1-git-send-email-rpeterso@redhat.com> References: <1457033515-7521-1-git-send-email-rpeterso@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 03 Mar 2016 19:31:57 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.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 patch moves the iomap infrastructure from its current location in exportfs.h to a new iomap.h. This may be used not only by nfs, but also by other file systems. This also adds an iomap function call to the address_space_operations. This will facilitate future improvements such as a more efficient fiemap for holey files. Hopefully it will one day be used for multipage writes as well. Signed-off-by: Bob Peterson --- include/linux/exportfs.h | 16 +--------------- include/linux/fs.h | 2 ++ include/linux/iomap.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 include/linux/iomap.h diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h index fa05e04..bb564c1 100644 --- a/include/linux/exportfs.h +++ b/include/linux/exportfs.h @@ -2,6 +2,7 @@ #define LINUX_EXPORTFS_H 1 #include +#include struct dentry; struct iattr; @@ -181,21 +182,6 @@ struct fid { * get_name is not (which is possibly inconsistent) */ -/* types of block ranges for multipage write mappings. */ -#define IOMAP_HOLE 0x01 /* no blocks allocated, need allocation */ -#define IOMAP_DELALLOC 0x02 /* delayed allocation blocks */ -#define IOMAP_MAPPED 0x03 /* blocks allocated @blkno */ -#define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */ - -#define IOMAP_NULL_BLOCK -1LL /* blkno is not valid */ - -struct iomap { - sector_t blkno; /* first sector of mapping */ - loff_t offset; /* file offset of mapping, bytes */ - u64 length; /* length of mapping, bytes */ - int type; /* type of mapping */ -}; - struct export_operations { int (*encode_fh)(struct inode *inode, __u32 *fh, int *max_len, struct inode *parent); diff --git a/include/linux/fs.h b/include/linux/fs.h index daf399d..6ae2b37 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -316,6 +317,7 @@ enum positive_aop_returns { struct page; struct address_space; struct writeback_control; +struct iomap; #define IOCB_EVENTFD (1 << 0) #define IOCB_APPEND (1 << 1) diff --git a/include/linux/iomap.h b/include/linux/iomap.h new file mode 100644 index 0000000..0026258 --- /dev/null +++ b/include/linux/iomap.h @@ -0,0 +1,29 @@ +#ifndef _IOMAP_H +#define _IOMAP_H + +/* iomap flags */ +#define IOMAP_MODE_READ 0x01 /* iomap operation requires RO lock */ +#define IOMAP_MODE_RDWR 0x02 /* iomap operation requires R/W lock */ + +/* types of block ranges for multipage write mappings. */ +#define IOMAP_HOLE 0x01 /* no blocks allocated, need allocation */ +#define IOMAP_DELALLOC 0x02 /* delayed allocation blocks */ +#define IOMAP_MAPPED 0x03 /* blocks allocated @blkno */ +#define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */ + +#define IOMAP_NULL_BLOCK -1LL /* blkno is not valid */ + +struct iomap { + sector_t blkno; /* first sector of mapping */ + loff_t offset; /* file offset of mapping, bytes */ + ssize_t length; /* length of mapping, bytes */ + int type; /* type of mapping */ + void *priv; /* fs private data associated with map */ +}; + +static inline bool iomap_needs_allocation(struct iomap *iomap) +{ + return iomap->type == IOMAP_HOLE; +} + +#endif /* _IOMAP_H */