From patchwork Wed Jan 25 02:38:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9536307 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 B1C2B60434 for ; Wed, 25 Jan 2017 02:38:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A24B726E96 for ; Wed, 25 Jan 2017 02:38:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9478C27BA5; Wed, 25 Jan 2017 02:38:38 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 0F72626E96 for ; Wed, 25 Jan 2017 02:38:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751220AbdAYCif (ORCPT ); Tue, 24 Jan 2017 21:38:35 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:35586 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750984AbdAYCif (ORCPT ); Tue, 24 Jan 2017 21:38:35 -0500 Received: by mail-pf0-f182.google.com with SMTP id f144so54435133pfa.2 for ; Tue, 24 Jan 2017 18:38:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=1KAYdXFcdSj8CsQxtOaX2NlimoF80OVVFfPiRLxXZb4=; b=At3CPgdzMGTZ0H4UCC3iCIbPi+BFPO2ZCqaNMkzh7Qvc0g9Rue2+NQIVQ2dUP4ekx7 ls+0UihZLfNRepNkeTws4Y0ZyxyMMgIp6XYivt/ttiO3fRx/iOg8hntxo8xBH5S5q2Fc KdI6MxqvtA6rXykJLoYJx/8MeZTfQt403rgCjTPy70Ig0z9A0yQSuH4vRNlYUpXmNsqb yPrRLHhbGOTgOq6bMRk6Gfa2lPCT7oHhvTjOykmHLB663AYy1j0fwMD9iAR+1mA6Q6kG ct5HubMkVcVEvYGt0QpvZT2asQQVL34iCIqe6QC6wYxKuR1s1RyZGvi2wbWCbLe0PF0X bjSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1KAYdXFcdSj8CsQxtOaX2NlimoF80OVVFfPiRLxXZb4=; b=rbsRKtdm+uFo1WxiyLJPg+R5zc5Ekgo8o1Gy/xP9JvJyZTofih23kDttK5cCxRLgRw J8TMy6Djgd2fnMPtjHh8F0Mzmvr9psIEsPJY5caT71CL3wIecekRo/fcorf04NDavmY6 XJVFUzSEBe27yhDdAltpZoBD08WoXLt8UAd4aCp+FClRIKFFL1DJ+hx2wfWtwoGUUARp Ov8Rw5gsvOPYDyuDf3/j5v6XfK4d52nU4OfaU9XeNCnOaNg1mFcVZ2RMQHclufWWlngj xYx8HaY4enp0ponHqA1NlBP0zaRBSb/RylJeYb35+g+sxCo1Rzg2xCFm37DALCmFGnn3 nvpQ== X-Gm-Message-State: AIkVDXLevtgrz/84puES5VWIX63VjcZHPqkCmpVatEw75wpGoyWbVF/tvPba4Tf51GaohqUb X-Received: by 10.98.200.207 with SMTP id i76mr43383868pfk.38.1485311914012; Tue, 24 Jan 2017 18:38:34 -0800 (PST) Received: from localhost.localdomain ([2601:602:8801:8110:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id e189sm47564997pfg.64.2017.01.24.18.38.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 18:38:33 -0800 (PST) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: Chris Murphy , kernel-team@fb.com, Andreas Gruenbacher Subject: [PATCH] Btrfs: disable xattr operations on subvolume directories Date: Tue, 24 Jan 2017 18:38:02 -0800 Message-Id: X-Mailer: git-send-email 2.11.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval When you snapshot a subvolume containing a subvolume, you get a placeholder read-only directory where the subvolume would be. These directory inodes have ->i_ops set to btrfs_dir_ro_inode_operations. Previously, this didn't include the xattr operation callbacks. The conversion to xattr_handlers missed this case, leading to bogus attempts to set xattrs on these inodes. This manifested itself as failures when running delayed inodes. To fix this, clear the IOP_XATTR in ->i_opflags on these inodes. Fixes: 6c6ef9f26e59 ("xattr: Stop calling {get,set,remove}xattr inode operations") Cc: Andreas Gruenbacher Reported-by: Chris Murphy Signed-off-by: Omar Sandoval --- Applies to v4.10-rc4. Chris, this fixes the issue for me, could you please test it out? Andreas, does this make sense? I'll try to cook up an xfstest for this. fs/btrfs/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 4e024260ad71..3dacf0786428 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3835,10 +3835,12 @@ static int btrfs_read_locked_inode(struct inode *inode) break; case S_IFDIR: inode->i_fop = &btrfs_dir_file_operations; - if (root == fs_info->tree_root) + if (root == fs_info->tree_root) { inode->i_op = &btrfs_dir_ro_inode_operations; - else + inode->i_opflags &= ~IOP_XATTR; + } else { inode->i_op = &btrfs_dir_inode_operations; + } break; case S_IFLNK: inode->i_op = &btrfs_symlink_inode_operations; @@ -5710,6 +5712,7 @@ static struct inode *new_simple_dir(struct super_block *s, inode->i_ino = BTRFS_EMPTY_SUBVOL_DIR_OBJECTID; inode->i_op = &btrfs_dir_ro_inode_operations; + inode->i_opflags &= ~IOP_XATTR; inode->i_fop = &simple_dir_operations; inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO; inode->i_mtime = current_time(inode);