From patchwork Thu Apr 12 15:07:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10338671 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 1541060134 for ; Thu, 12 Apr 2018 15:08:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0996C26D08 for ; Thu, 12 Apr 2018 15:08:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F206A26E74; Thu, 12 Apr 2018 15:08:47 +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=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 A65DE26D08 for ; Thu, 12 Apr 2018 15:08:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753352AbeDLPIp (ORCPT ); Thu, 12 Apr 2018 11:08:45 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39783 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753160AbeDLPIk (ORCPT ); Thu, 12 Apr 2018 11:08:40 -0400 Received: by mail-wm0-f67.google.com with SMTP id b21so10271648wme.4 for ; Thu, 12 Apr 2018 08:08:39 -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=CCjMOQrIGFKtqEAM00uC0a1N05TGc5+lbGZbLFJT2tU=; b=lEoNsHCWM4Sm6raHsHv3qnXO6XNfVCQ7jr+OD1wrwtBQpBLlcty5cDZs+Ax2oacDWk za1K3krSNuyr80T1QWhO2A+BnUyJ/RCo2CzxW6SBknVUdgqzDPltKfV99b+qTJJe3XRm bT0nfttnj3gRTrl17UU1ejKNZ7JVP2KHAWsIIQgr5DlSaTmZWIttpArQiX+aF6FTFTzR c0vXYuyKW/uqyXldnGZa5Jg2ajYXXYOVQYFKjzIwpoCEJqMr3X6TxcokJU5SmNEG7x6f 9pBXc9O3tnLNMYRdmx4IcN/GkFyabcXXMO/BwRgioLkmdQeKKdoh7eNkEMkI5YYVU27f eYqQ== X-Gm-Message-State: ALQs6tDHOItNVcA/ncsBePO8NWTGv4NRgTFXm0mDxqUKCRQtYz70flri 6CqFnl7kk8FDBX3SURRn69ysiw== X-Google-Smtp-Source: AIpwx49YmEhGOuYJw+Wp8TnONGRYvNwdQtG2SjMLircjW6zM92tGyNKDCRj6M8N9jrHVai7uSBUQfQ== X-Received: by 10.28.237.3 with SMTP id l3mr1056494wmh.125.1523545718614; Thu, 12 Apr 2018 08:08:38 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id p197sm2621783wme.43.2018.04.12.08.08.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:08:38 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 06/35] Revert "Revert "ovl: get_write_access() in truncate"" Date: Thu, 12 Apr 2018 17:07:57 +0200 Message-Id: <20180412150826.20988-7-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180412150826.20988-1-mszeredi@redhat.com> References: <20180412150826.20988-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 33635106c5f7..e213bb9823ec 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;