Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1992552ybh; Tue, 14 Jul 2020 12:32:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw54pJY2Duk6M0jlVNlfuq9a33LONus5BDQkDWqfbThPT+zH4sgJ1/l+JHQb4ColOIKmhSu X-Received: by 2002:a17:906:4acc:: with SMTP id u12mr5925795ejt.358.1594755134749; Tue, 14 Jul 2020 12:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594755134; cv=none; d=google.com; s=arc-20160816; b=JJiBObvrqYsaliBbTsez4l/0A/8qcyBRc74V3Xhdx+H1ttZ4kDk7XnwVWL9UoidEO3 Y+sW47vYHNABYZhP/NzVgMt6Bw7t2wKGgHYWaJtvtEDLfMBArbU5jjqdQkTBOXyVd2i4 m2O8W/BHjUdg+yD9Ntx1xLQ1c+8lpu+CBclfH/3rr0mcTGiW1JwMFi3KBOUwBHbJ7Pau hCVOWaRtp9rfn1bchmp3Lke4yn1BWkDSHTelaBMZvgj0grAtV7MT4JlEeQzMxqjiRVjn BPrOH3bx32+HYy+6nP2UcDZb6pwRwTg5UfP5HLltNniuz8EAZGEYomlvlOmTCBUOASew JlGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=cPk5LMoGoThBA0eFxbivhO2pS56bC/86EhKFPKHKu4c=; b=a/WPwmJ++p9N2Uj8k2XDSAQ+jBE82MZl2pzlMlulVp5/89SQ/nqyc8pUV1G3B4Bugc arVMCrXzhgzCBUyGmrPe+PW1MfTDpvYqPR9EUkwZHYymbFy8r67qwIsdDBjVRK5/pbmV icpbeKql+xNiSJjmViAHFA8U90ODvydtTrd1L49IXek8WhNU6j8T/C/QrQo4DWnwqWon kf99KqGmC8wHRN1EOPnB2SJcHcL7cX+vWtpeYmENCcRlTfgfUl2W+vT2LUzx4q+kQxiZ HIW9ppunbKWMmYM9iTnd62+xfveYMXM9tDsyVSFszVOIXijhqEnrjTkve/LRTdt7L0TQ QJ0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=VLmnr+RK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si10709531ejw.207.2020.07.14.12.31.49; Tue, 14 Jul 2020 12:32:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=VLmnr+RK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729261AbgGNTbX (ORCPT + 99 others); Tue, 14 Jul 2020 15:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728428AbgGNTbX (ORCPT ); Tue, 14 Jul 2020 15:31:23 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76E1AC061794 for ; Tue, 14 Jul 2020 12:31:22 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id e4so24968091ljn.4 for ; Tue, 14 Jul 2020 12:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cPk5LMoGoThBA0eFxbivhO2pS56bC/86EhKFPKHKu4c=; b=VLmnr+RKkXZkAascGHD+AaCNa6Y2XPywcyp6v/mdbuMkz/hf+hhfE1/nd7RM0JXapm cVYAMBvwJI3Gd5pMjW+DZXpL4Lk84F0PSZHOcvKhlEII13xTPasta+T1CpQkTxCpx6DR hsyOPnSmMSJKICLP2tLHfz+bnE3r2Zf/mvQgo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cPk5LMoGoThBA0eFxbivhO2pS56bC/86EhKFPKHKu4c=; b=J32LLnDh/amBZ1xOQ1t+vlpbl3cXBft/+zd4YbtCsy0VJA7/3IguE8SB6HEqzqX35Y SUYBS94sHsI5FCiJqj70fGg7x2s/g3Cy/jTamLnL86idPdWPLCVvMIL9nuAwrUGL7Oq8 EjK0FREbB4NTzK62lBmxGqRug9yKICeaTAMM6nv0heZo7ZWws96EgWjmTdxVT96kIQv8 sCk8+eJ352fciO5m0WSFy4Y6QsOCi+dxOH+SEPj5zePuX9oVCz4vhQ6dU0WgSx43v/M/ 26fhJpTaPb+alLAfn8a9UiqkXQMCzNUp/dqmaqSe3OPklewS49w65aHWaR0ecIkNcduS svrg== X-Gm-Message-State: AOAM530ympgcDq5r23Ae9R6VXEL0AI7c+yF1AL59C+eC96HjRGq5HoQL S6pBHa8Yi9/ezdHbOTJ147a9i1QmiTY= X-Received: by 2002:a05:651c:30b:: with SMTP id a11mr1570468ljp.126.1594755080559; Tue, 14 Jul 2020 12:31:20 -0700 (PDT) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com. [209.85.208.169]) by smtp.gmail.com with ESMTPSA id i16sm1759ljn.50.2020.07.14.12.31.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jul 2020 12:31:19 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id h19so24972009ljg.13 for ; Tue, 14 Jul 2020 12:31:18 -0700 (PDT) X-Received: by 2002:a2e:86c4:: with SMTP id n4mr3168247ljj.312.1594755078276; Tue, 14 Jul 2020 12:31:18 -0700 (PDT) MIME-Version: 1.0 References: <20200714190427.4332-1-hch@lst.de> <20200714190427.4332-18-hch@lst.de> In-Reply-To: <20200714190427.4332-18-hch@lst.de> From: Linus Torvalds Date: Tue, 14 Jul 2020 12:31:01 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 17/23] initramfs: switch initramfs unpacking to struct file based APIs To: Christoph Hellwig Cc: Linux Kernel Mailing List , "H. Peter Anvin" , Song Liu , Al Viro , linux-raid@vger.kernel.org, linux-fsdevel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 14, 2020 at 12:09 PM Christoph Hellwig wrote: > > There is no good reason to mess with file descriptors from in-kernel > code, switch the initramfs unpacking to struct file based write > instead. Looking at this diff, I realized this really should be cleaned up more. + wfile = filp_open(collected, openflags, mode); > + if (IS_ERR(wfile)) > + return 0; > + > + vfs_fchown(wfile, uid, gid); > + vfs_fchmod(wfile, mode); > + if (body_len) > + vfs_truncate(&wfile->f_path, body_len); > + vcollected = kstrdup(collected, GFP_KERNEL); That "vcollected" is ugly and broken, and seems oh-so-wrong. Because it's only use is: > - ksys_close(wfd); > + fput(wfile); > do_utime(vcollected, mtime); > kfree(vcollected); which should just have done the exact same thing that you did with vfs_chown() and friends: we already have a "utimes_common()" that takes a path, and it could have been made into "vfs_utimes()", and then this whole vcollected confusion would go away and be replaced by vfs_truncate(&wfile->f_path, mtime); (ok, with all the "timespec64 t[2]" things going on that do_utime() does now, but you get the idea). Talk about de-crufting that initramfs unpacking.. But I don't hate this patch, I'm just pointing out that there's room for improvement. Linus