From patchwork Mon Aug 8 06:22:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 9266759 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 F2BB8607D6 for ; Mon, 8 Aug 2016 06:23:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E200B279B3 for ; Mon, 8 Aug 2016 06:23:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6CBE27BFC; Mon, 8 Aug 2016 06:23:04 +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 793B7279B3 for ; Mon, 8 Aug 2016 06:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169AbcHHGXD (ORCPT ); Mon, 8 Aug 2016 02:23:03 -0400 Received: from ipmail06.adl2.internode.on.net ([150.101.137.129]:43979 "EHLO ipmail06.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750916AbcHHGXB (ORCPT ); Mon, 8 Aug 2016 02:23:01 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuoSAAgkqFd5LDUCIGdsb2JhbABdg0VWfIZynRcGknGEKIczTQEBAQEBAQcBAQEBAQE4QIRfBicvIxAIGDE5AwcUGYgwwxWFYod0hzwFmTmGHYhvgWmIDYVLkCyCFQGCSioyhz8BAQE Received: from ppp121-44-53-2.lns20.syd4.internode.on.net (HELO dastard) ([121.44.53.2]) by ipmail06.adl2.internode.on.net with ESMTP; 08 Aug 2016 15:52:57 +0930 Received: from disappointment.disaster.area ([192.168.1.110] helo=disappointment) by dastard with esmtp (Exim 4.80) (envelope-from ) id 1bWdxf-0001GI-Qz; Mon, 08 Aug 2016 16:22:55 +1000 Received: from dave by disappointment with local (Exim 4.87) (envelope-from ) id 1bWdxJ-0007Jd-Ib; Mon, 08 Aug 2016 16:22:33 +1000 From: Dave Chinner To: xfs@oss.sgi.com Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 2/2] iomap: add fiemap support for attribute mappings Date: Mon, 8 Aug 2016 16:22:31 +1000 Message-Id: <1470637351-27933-3-git-send-email-david@fromorbit.com> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1470637351-27933-1-git-send-email-david@fromorbit.com> References: <1470637351-27933-1-git-send-email-david@fromorbit.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Chinner Prior to the iomap conversion, XFS supported the FIEMAP_FLAG_XATTR flag for mapping the attribute fork block map. This flag was not added to the iomap fiemap support so we have regressed fiemap functionality with this change. Add an iomap control flag to indicate that we should be operating on the attribute map rather than the file data map and pass it from iomap_fiemap() as appropriate. Add the appropriate flags to the XFS code to switch to the attribute fork lookup, and ensure we return EINVAL if anyone attempts a write mapping of the attribute fork. Signed-off-by: Dave Chinner --- fs/iomap.c | 11 +++++++++-- fs/xfs/xfs_iomap.c | 14 +++++++++++++- include/linux/iomap.h | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 189742b..2a04e5e 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -461,12 +461,13 @@ int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fi, { struct fiemap_ctx ctx; loff_t ret; + int flags = 0; memset(&ctx, 0, sizeof(ctx)); ctx.fi = fi; ctx.prev.type = IOMAP_HOLE; - ret = fiemap_check_flags(fi, FIEMAP_FLAG_SYNC); + ret = fiemap_check_flags(fi, FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR); if (ret) return ret; @@ -476,9 +477,15 @@ int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fi, return ret; } + if (fi->fi_flags & FIEMAP_FLAG_XATTR) + flags |= IOMAP_ATTR; + while (len > 0) { - ret = iomap_apply(inode, start, len, 0, ops, &ctx, + ret = iomap_apply(inode, start, len, flags, ops, &ctx, iomap_fiemap_actor); + /* inode with no attribute mapping will give ENOENT */ + if (ret == -ENOENT) + break; if (ret < 0) return ret; if (ret == 0) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 4398932..17b5b82 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -993,10 +993,22 @@ xfs_file_iomap_begin( struct xfs_bmbt_irec imap; xfs_fileoff_t offset_fsb, end_fsb; int nimaps = 1, error = 0; + int bmflags = XFS_BMAPI_ENTIRE; if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; + /* Attribute fork can only be read via this interface */ + if (flags & IOMAP_ATTR) { + if (flags & ~IOMAP_ATTR) + return -EINVAL; + /* if there are no attribute fork or extents, return ENOENT */ + if (!XFS_IFORK_Q(ip) || !ip->i_d.di_anextents) + return -ENOENT; + ASSERT(ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL); + bmflags |= XFS_BMAPI_ATTRFORK; + } + xfs_ilock(ip, XFS_ILOCK_EXCL); ASSERT(offset <= mp->m_super->s_maxbytes); @@ -1006,7 +1018,7 @@ xfs_file_iomap_begin( end_fsb = XFS_B_TO_FSB(mp, offset + length); error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap, - &nimaps, XFS_BMAPI_ENTIRE); + &nimaps, bmflags); if (error) { xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 3267df4..00a5477 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -36,6 +36,7 @@ struct iomap { */ #define IOMAP_WRITE (1 << 0) #define IOMAP_ZERO (1 << 1) +#define IOMAP_ATTR (1 << 2) /* operate on attributes */ struct iomap_ops { /*