From patchwork Mon May 7 08:37:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10383631 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 36EFB60159 for ; Mon, 7 May 2018 08:49:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C48028B60 for ; Mon, 7 May 2018 08:49:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2120D28B64; Mon, 7 May 2018 08:49:17 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 C665528B60 for ; Mon, 7 May 2018 08:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752233AbeEGItD (ORCPT ); Mon, 7 May 2018 04:49:03 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34218 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752101AbeEGIiY (ORCPT ); Mon, 7 May 2018 04:38:24 -0400 Received: by mail-wm0-f68.google.com with SMTP id a137-v6so14175681wme.1 for ; Mon, 07 May 2018 01:38:23 -0700 (PDT) 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:in-reply-to :references; bh=CCEbqsXOFa/48LfjQR7k7TFJZxTNvW5VjnU+Bf0jRII=; b=BlqgAhb0C8jg6aiR86ZQOZ+GTs9fjDcz4XCo8D+eH9YLpic0UtmQrjSPjz5mUA9gWy tsodBvfcv2VtH9htm3Gkx/2zt0DlYpz9H3z/MLnMDx9GEfTcOnJny9B6hew5jx6cnvNT Nv7NqbIolObJmAnXhEv6PHkP3Mb2Q5VhmKIxtZGAfevbTR6LK3aslKDOttqsGbJb6jit QKGJMecMQeorLNEesFOnw7FcfMGei8Y0/4Z0wV0DOLPeSzuAB8+cAFAmRPwstBmagcEk POsH0eTY83HjsyNE4dc5SsxC7nOQgfIZXK78MkjmwbfsTIY1bKJp17fVrx3yCUzaYCJ3 JCfQ== X-Gm-Message-State: ALKqPwdQVWo4x04orELQuBfnzyC834X9Clt1R3WgOZYeBN7JnzPNPBXs V2fJS6Pay3KttXykANg/LgA+Yw== X-Google-Smtp-Source: AB8JxZqESsP7VhZn9I0WzHS/bgyr1hTpu8w8Z90N2m9fZMiC/Qi2dPHThFT4ZejdRuqWoa08qLIqRQ== X-Received: by 2002:a1c:ec4b:: with SMTP id k72-v6mr179795wmh.27.1525682302391; Mon, 07 May 2018 01:38:22 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (C2B0E321.catv.pool.telekom.hu. [194.176.227.33]) by smtp.gmail.com with ESMTPSA id h8-v6sm5908050wmc.16.2018.05.07.01.38.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 May 2018 01:38:21 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 08/35] Revert "Revert "ovl: get_write_access() in truncate"" Date: Mon, 7 May 2018 10:37:40 +0200 Message-Id: <20180507083807.28792-9-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180507083807.28792-1-mszeredi@redhat.com> References: <20180507083807.28792-1-mszeredi@redhat.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 This reverts commit 31c3a7069593b072bd57192b63b62f9a7e994e9a. Re-add functionality dealing with i_writecount on truncate to overlayfs. This patch shouldn't have any observable effects, since we just re-assert the writecout that vfs_truncate() already got for us. This is in preparation for moving overlay functionality out of the VFS. Signed-off-by: Miklos Szeredi --- fs/overlayfs/inode.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index d3700f0de165..f7b1910bb9d4 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -39,10 +39,27 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr) if (err) goto out; + if (attr->ia_valid & ATTR_SIZE) { + struct inode *realinode = d_inode(ovl_dentry_real(dentry)); + + err = -ETXTBSY; + if (atomic_read(&realinode->i_writecount) < 0) + goto out_drop_write; + } + err = ovl_copy_up(dentry); if (!err) { + struct inode *winode = NULL; + upperdentry = ovl_dentry_upper(dentry); + if (attr->ia_valid & ATTR_SIZE) { + winode = d_inode(upperdentry); + err = get_write_access(winode); + if (err) + goto out_drop_write; + } + if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) attr->ia_valid &= ~ATTR_MODE; @@ -53,7 +70,11 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr) if (!err) ovl_copyattr(upperdentry->d_inode, dentry->d_inode); inode_unlock(upperdentry->d_inode); + + if (winode) + put_write_access(winode); } +out_drop_write: ovl_drop_write(dentry); out: return err;