From patchwork Tue May 29 14:43:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10436109 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 41640601C7 for ; Tue, 29 May 2018 15:13:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32EA5286F5 for ; Tue, 29 May 2018 15:13:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2765928768; Tue, 29 May 2018 15:13: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 CB8BC286F5 for ; Tue, 29 May 2018 15:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935624AbeE2OoD (ORCPT ); Tue, 29 May 2018 10:44:03 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:50984 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935581AbeE2Onz (ORCPT ); Tue, 29 May 2018 10:43:55 -0400 Received: by mail-wm0-f67.google.com with SMTP id t11-v6so41396795wmt.0 for ; Tue, 29 May 2018 07:43:54 -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=3ii8H7OTOfRj1bGoN4l4fNS2FCGQFFXhPFKj+gRkUfc=; b=gFuBFoNS8Qjs2SAHwDvNo+PVlznYrIvn4p8jDwDJElai8Z29hEMmfz5i+3LOaWoGVx WWi6Pf2ZdYXO4CUbkWQFf1QQakYI7rjhxuEUsb+el/AzldOnP0KnfXJhQvQMbmfXhFHO YNVMNh/UqYlzzy+GigAu0NGig9UJi9t5Sob+ZrAosI76jLB4fsDu7PQxSHODTazSU3ub 615wjUoF6r4fU2ACZKbzc5o5iwO1/DzImqc/vMHzKI+CUKptZpj3pEB8ziOgQbmtzHTV eINIvX7i0U5NXgkAWUe/5HZ6VDGetVUQ0jaN7YJKzlsOUyWnvb7RHOJifCCLH2z5wpy4 K6aA== X-Gm-Message-State: ALKqPwdBzVaWa8gQ1OploiT8IhlpTe+p6KpyKAucjzhHN34M2iqrAKlj LaSxNRMXMfIUANFzhAD88y0QLg== X-Google-Smtp-Source: ADUXVKJzZw+/E1SUQY8Kgrx2YndQkpv3daRwMg/d1ye3+Auiv2mbBGgNnfnVWT16FuVX6/8t6mVejg== X-Received: by 2002:a1c:b4e:: with SMTP id 75-v6mr10655262wml.32.1527605034289; Tue, 29 May 2018 07:43:54 -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 t198-v6sm18834422wmt.23.2018.05.29.07.43.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:43:53 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/39] Revert "Revert "ovl: get_write_access() in truncate"" Date: Tue, 29 May 2018 16:43:11 +0200 Message-Id: <20180529144339.16538-12-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529144339.16538-1-mszeredi@redhat.com> References: <20180529144339.16538-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 24fc27683a57..0116ec12451d 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;