From patchwork Mon Sep 19 14:10:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12980500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6772EECAAD3 for ; Mon, 19 Sep 2022 14:10:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbiISOKr (ORCPT ); Mon, 19 Sep 2022 10:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbiISOKm (ORCPT ); Mon, 19 Sep 2022 10:10:42 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 242E83136D for ; Mon, 19 Sep 2022 07:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663596638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PzsiJLh4qivuvaD01T8k0cktWemsb5i0yo5HxUE+jT4=; b=PPlScce04HFIG6QRSHuTlhZBKBNCQqC0pX5i262shvZ7S7SB3qgPH42jbm2/kgNPFd4DG7 HM3s3BrCHNhZ6cPQzyNqFPafmOdsCk5Vv3afUI6zY31zNSgSjzE/vZU9IzVwqcBnlB3ByQ fWsvEU3zmG1ukUO/HeZKzGF9wUoqV5s= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-670-a8lr2fz7MMiKpTRVFQBN7Q-1; Mon, 19 Sep 2022 10:10:37 -0400 X-MC-Unique: a8lr2fz7MMiKpTRVFQBN7Q-1 Received: by mail-ej1-f70.google.com with SMTP id go7-20020a1709070d8700b007793ffa7c44so10660954ejc.1 for ; Mon, 19 Sep 2022 07:10:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=PzsiJLh4qivuvaD01T8k0cktWemsb5i0yo5HxUE+jT4=; b=AeD1+52B0pGj5i8FtB1FFy1SjDNI7j1KHnggEH66XAHLsVAOMyJWksSe4iTmnDbQJt 5Pn1c11mbr9GI8tJDM8vYM26TMnyorYxC4pKB5VX2o6rDDL+lTdL6Uz2S8RK5L4sHIdg 8RykDTqqmuZ0/lpnJlF9smMpHrLmHCskLI/rg/T9KBaSCHUhbhF4Qd4LyW8s38paEtDa X2foX9b7WgBDHt1vfL9Z0I+1NVuk8SFo1vrc0mLuVci9UlP6T9WD1+3pOvo7lXy07X5F LjgoG4gP1zviP2h9d3qz1HS3oLpJFSeTNx+F7x+l+R7YzNjMIVOATBLFGdIHVAG4hZv0 I78g== X-Gm-Message-State: ACrzQf3bOF0Ouptcdp3ym2igfR25H9CPhhDQMP+tupk3QsgF9esOwgUx 2dzhDEaYE3Mz0BRAvdhUdZUUrj977Zw1Q/KL4Rs1Kg3xPy4J8oaYhJI3cFGv48ebZ1HaMOH8Cn6 t+Wreu3hRxcAr4cJefZJGuJDhC/4oVkmc8zFCdHO64h8BpsNvY0r0heTdQiOJHPYlpA2sn/gHcS uuzA== X-Received: by 2002:a17:906:fe4a:b0:781:3b6:f8b0 with SMTP id wz10-20020a170906fe4a00b0078103b6f8b0mr7144469ejb.183.1663596635583; Mon, 19 Sep 2022 07:10:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM49ZD8FDPG7yWlQMbndETaJ5I7VPYZTyruyRnOhRQY5crmhN6aO/+aVrIRE8qrk1uPISeGOtA== X-Received: by 2002:a17:906:fe4a:b0:781:3b6:f8b0 with SMTP id wz10-20020a170906fe4a00b0078103b6f8b0mr7144444ejb.183.1663596635380; Mon, 19 Sep 2022 07:10:35 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-214-223.pool.digikabel.hu. [193.226.214.223]) by smtp.gmail.com with ESMTPSA id lb22-20020a170907785600b0073bdf71995dsm9849951ejc.139.2022.09.19.07.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 07:10:35 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Al Viro , Amir Goldstein , David Howells , Yu-li Lin , Chirantan Ekbote Subject: [PATCH v2 1/8] cachefiles: tmpfile error handling cleanup Date: Mon, 19 Sep 2022 16:10:24 +0200 Message-Id: <20220919141031.1834447-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919141031.1834447-1-mszeredi@redhat.com> References: <20220919141031.1834447-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Separate the error labels from the success path and use 'ret' to store the error value before jumping to the error label. Signed-off-by: Miklos Szeredi --- fs/cachefiles/namei.c | 55 ++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index facf2ebe464b..d3a5884fe5c9 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -460,31 +460,27 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object) path.mnt = cache->mnt; ret = cachefiles_inject_write_error(); - if (ret == 0) + if (ret == 0) { path.dentry = vfs_tmpfile(&init_user_ns, fan, S_IFREG, O_RDWR); - else - path.dentry = ERR_PTR(ret); - if (IS_ERR(path.dentry)) { - trace_cachefiles_vfs_error(object, d_inode(fan), PTR_ERR(path.dentry), + ret = PTR_ERR_OR_ZERO(path.dentry); + } + if (ret) { + trace_cachefiles_vfs_error(object, d_inode(fan), ret, cachefiles_trace_tmpfile_error); - if (PTR_ERR(path.dentry) == -EIO) + if (ret == -EIO) cachefiles_io_error_obj(object, "Failed to create tmpfile"); - file = ERR_CAST(path.dentry); - goto out; + goto err; } trace_cachefiles_tmpfile(object, d_backing_inode(path.dentry)); - if (!cachefiles_mark_inode_in_use(object, path.dentry)) { - file = ERR_PTR(-EBUSY); - goto out_dput; - } + ret = -EBUSY; + if (!cachefiles_mark_inode_in_use(object, path.dentry)) + goto err_dput; ret = cachefiles_ondemand_init_object(object); - if (ret < 0) { - file = ERR_PTR(ret); - goto out_unuse; - } + if (ret < 0) + goto err_unuse; ni_size = object->cookie->object_size; ni_size = round_up(ni_size, CACHEFILES_DIO_BLOCK_SIZE); @@ -499,36 +495,37 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object) trace_cachefiles_vfs_error( object, d_backing_inode(path.dentry), ret, cachefiles_trace_trunc_error); - file = ERR_PTR(ret); - goto out_unuse; + goto err_unuse; } } file = open_with_fake_path(&path, O_RDWR | O_LARGEFILE | O_DIRECT, d_backing_inode(path.dentry), cache->cache_cred); + ret = PTR_ERR(file); if (IS_ERR(file)) { trace_cachefiles_vfs_error(object, d_backing_inode(path.dentry), - PTR_ERR(file), - cachefiles_trace_open_error); - goto out_unuse; + ret, cachefiles_trace_open_error); + goto err_unuse; } + ret = -EINVAL; if (unlikely(!file->f_op->read_iter) || unlikely(!file->f_op->write_iter)) { fput(file); pr_notice("Cache does not support read_iter and write_iter\n"); - file = ERR_PTR(-EINVAL); - goto out_unuse; + goto err_unuse; } - - goto out_dput; - -out_unuse: - cachefiles_do_unmark_inode_in_use(object, path.dentry); -out_dput: dput(path.dentry); out: cachefiles_end_secure(cache, saved_cred); return file; + +err_unuse: + cachefiles_do_unmark_inode_in_use(object, path.dentry); +err_dput: + dput(path.dentry); +err: + file = ERR_PTR(ret); + goto out; } /* From patchwork Mon Sep 19 14:10:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12980501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80C37C54EE9 for ; Mon, 19 Sep 2022 14:10:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229529AbiISOKt (ORCPT ); Mon, 19 Sep 2022 10:10:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbiISOKm (ORCPT ); Mon, 19 Sep 2022 10:10:42 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C7015FCB for ; Mon, 19 Sep 2022 07:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663596640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=anOQA/oJUS71LYPqHcQLEIYyutVeIxZG9umMeWdqoZk=; b=V/ZAsfouujEVbTfSOQY8qyxd6254F8E9jcuZVeq+1E9RfFZRcTdrcytK38QkygXKJY3a1M XLHIB4X0zxAlDzvsCQdCTbbIE43eX+FOym+gi09s6iNmC4cLuUsXMex0DTsxhdpC8J9DJ3 eVygwIAMbI7My7tsDXsLMylzzDTFPUE= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-542-SqyZrmtpPxuCe-e0graiiw-1; Mon, 19 Sep 2022 10:10:38 -0400 X-MC-Unique: SqyZrmtpPxuCe-e0graiiw-1 Received: by mail-ed1-f69.google.com with SMTP id c6-20020a05640227c600b004521382116dso15417154ede.22 for ; Mon, 19 Sep 2022 07:10:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=anOQA/oJUS71LYPqHcQLEIYyutVeIxZG9umMeWdqoZk=; b=7iCBzTBARBOO0UdrWySZrne9jUSujBWA1JzH2rANbDfqv2yuIx7DxOQJkI9vInmsW1 XhNJDgDS1qser4MPQ5KLn93FTXxqpo2Dt6W2/V8PNlxtAbr4LxT8n7Kcl/5imgkTSpCM xWCV4mpHdSuUUR1zUy+PC93frb17iwKtRXqEcEjJUxHWS6T2JWJTeq3H0VhueBGNBeTT 5mD6dYpkDx8Rz6oO8pusZF8o/RUKR4pwVuS+GLM/iNnVfRF1QxAdGBbcSd5nRSpHJHPg ENKu0u8AAAQbqZ6wJkDf8BsepGsgKmM1YTCWuFxMat+OEYkIfihc/CwQ/IPrZ+7lfxZu KFCg== X-Gm-Message-State: ACrzQf2osqIrphs+WxKdkz465xHBVfAOUIE4YRAqQr0ivfyIiqSraEey 52jaiqExwt1s5W4MaGwFQLL7bLN3tJiaPOQ+g/WsWXjxB7Wcz/AQ71PfNxEfBjsd4mquWzrpK6f DuiNFrF1JiUkiBSktMR5Fj+jPflWrrrSI80yGe1Yr2KauQq1EUozZO9dCjQdU3PSWmDvLe6hUoA eHUQ== X-Received: by 2002:a05:6402:34cb:b0:451:61c9:a316 with SMTP id w11-20020a05640234cb00b0045161c9a316mr16334077edc.268.1663596636710; Mon, 19 Sep 2022 07:10:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4rMjhU4aBxmJYnr3cEmmYBTFIL1SwBoJDwDS9Vj/QnCalbOWDpSNyrscGJKA2crEGHkA79pg== X-Received: by 2002:a05:6402:34cb:b0:451:61c9:a316 with SMTP id w11-20020a05640234cb00b0045161c9a316mr16334049edc.268.1663596636416; Mon, 19 Sep 2022 07:10:36 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-214-223.pool.digikabel.hu. [193.226.214.223]) by smtp.gmail.com with ESMTPSA id lb22-20020a170907785600b0073bdf71995dsm9849951ejc.139.2022.09.19.07.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 07:10:35 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Al Viro , Amir Goldstein , David Howells , Yu-li Lin , Chirantan Ekbote Subject: [PATCH v2 2/8] vfs: add tmpfile_open() helper Date: Mon, 19 Sep 2022 16:10:25 +0200 Message-Id: <20220919141031.1834447-3-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919141031.1834447-1-mszeredi@redhat.com> References: <20220919141031.1834447-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This helper unifies tmpfile creation with opening. Existing vfs_tmpfile() callers outside of fs/namei.c will be converted to using this helper. There are two such callers: cachefile and overlayfs. The cachefiles code currently uses the open_with_fake_path() helper to open the tmpfile, presumably to disable accounting of the open file. Overlayfs uses tmpfile for copy_up, which means these struct file instances will be short lived, hence it doesn't really matter if they are accounted or not. Disable accounting in this helper to, which should be okay for both caller. Add MAY_OPEN permission checking for consistency. Like for create(2) read/write permissions are not checked. Signed-off-by: Miklos Szeredi --- fs/namei.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 4 ++++ 2 files changed, 45 insertions(+) diff --git a/fs/namei.c b/fs/namei.c index 53b4bc094db2..5e4a0c59eef6 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3624,6 +3624,47 @@ struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, } EXPORT_SYMBOL(vfs_tmpfile); +/** + * tmpfile_open - open a tmpfile for kernel internal use + * @mnt_userns: user namespace of the mount the inode was found from + * @parentpath: path of the base directory + * @mode: mode of the new tmpfile + * @open_flag: flags + * @cred: credentials for open + * + * Create and open a temporary file. The file is not accounted in nr_files, + * hence this is only for kernel internal use, and must not be installed into + * file tables or such. + */ +struct file *tmpfile_open(struct user_namespace *mnt_userns, + const struct path *parentpath, + umode_t mode, int open_flag, const struct cred *cred) +{ + struct file *file; + int error; + struct path path = { .mnt = parentpath->mnt }; + + path.dentry = vfs_tmpfile(mnt_userns, parentpath->dentry, mode, open_flag); + if (IS_ERR(path.dentry)) + return ERR_CAST(path.dentry); + + error = may_open(mnt_userns, &path, 0, open_flag); + file = ERR_PTR(error); + if (error) + goto out_dput; + + /* + * This relies on the "noaccount" property of fake open, otherwise + * equivalent to dentry_open(). + */ + file = open_with_fake_path(&path, open_flag, d_inode(path.dentry), cred); +out_dput: + dput(path.dentry); + + return file; +} +EXPORT_SYMBOL(tmpfile_open); + static int do_tmpfile(struct nameidata *nd, unsigned flags, const struct open_flags *op, struct file *file) diff --git a/include/linux/fs.h b/include/linux/fs.h index 9eced4cc286e..34e7a189565b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2007,6 +2007,10 @@ static inline int vfs_whiteout(struct user_namespace *mnt_userns, struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, struct dentry *dentry, umode_t mode, int open_flag); +struct file *tmpfile_open(struct user_namespace *mnt_userns, + const struct path *parentpath, + umode_t mode, int open_flag, const struct cred *cred); + int vfs_mkobj(struct dentry *, umode_t, int (*f)(struct dentry *, umode_t, void *), void *); From patchwork Mon Sep 19 14:10:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12980502 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 864BCECAAD3 for ; Mon, 19 Sep 2022 14:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbiISOKu (ORCPT ); Mon, 19 Sep 2022 10:10:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbiISOKn (ORCPT ); Mon, 19 Sep 2022 10:10:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2114131EF9 for ; Mon, 19 Sep 2022 07:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663596640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BsXdvDdXKGBsyyVjzb1UKYoyRx8HM75Tqi022HaH4Io=; b=bGiTFG4zXcRcY1E/kGgOC9WEN7e7N7pmazChuhR9ayn4OBa+FrbnSMtSHxJhZ566SctcG1 F111+SbAVPqa0Yam7KtgXmYbskxi+2O2gm3Ii6Ogt4wK4bTXyu6nnhK8o4+Qt5uWuJV62m FUfnPGO+Q43Mnb5JkoDbc+iAlRW02Gc= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-207-AFha9x9FNWuNqh4r_JtrPQ-1; Mon, 19 Sep 2022 10:10:39 -0400 X-MC-Unique: AFha9x9FNWuNqh4r_JtrPQ-1 Received: by mail-ed1-f71.google.com with SMTP id w20-20020a05640234d400b00450f24c8ca6so20220812edc.13 for ; Mon, 19 Sep 2022 07:10:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=BsXdvDdXKGBsyyVjzb1UKYoyRx8HM75Tqi022HaH4Io=; b=zAVAJKzMQ4O/Zg2k1521estapQT+VTKmLPRA7uQtGo7iVY+iaQQO6eaH67/hCvuaJ4 l5f0UqqSyW5Nr34gGe1Z8M2t+gW3fxvkgIv/fJzgSaAgInzQrMHQQRCU0DIzlVQumvBj yMumQNcUhBS4rPLxGlXB1kGG47Pivyx4GT9uiXmeqacwagP7t/oxNo8qM74thwBr4iRO il6bolv4WbFtb0vx1cqA55/weTW5JIdeRfCQsiW+N4HPadeU9vZEyfsSvN+dyji1kp5W sNRsySt0zqAgIRqofM9aMIl033ktlScKrGN/Nos+HQeb9drGPGUunkcHZk1rOcwfIYu4 d8sQ== X-Gm-Message-State: ACrzQf0L4VuEK7VQ+bVuYxinUzINU/yD1xpfbGxd4a/0dNygInvEBZqs fIw+vxa4P/cZiBgMkpQjisWUL1j/J5GUT6qJWm79I/3+9FbJ4VM4g93K4Bjim+56w3Z+fv0UiwD yoCkAgcHxPKfAZewd4QdEqJMmre90PAWhd/itYvZvyoJCkFHk4FIm0IJoJQJdGVE5Jm+p59bNm7 EMmQ== X-Received: by 2002:a17:907:9714:b0:77b:e7a8:2f66 with SMTP id jg20-20020a170907971400b0077be7a82f66mr13272989ejc.107.1663596638220; Mon, 19 Sep 2022 07:10:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7uXI9H+uNxeq9FKnN99bzt71LLpGwB7rQAC0KMU6V9zJ675V7HrLHvOdTvw/Fj+j2OVmYrNA== X-Received: by 2002:a17:907:9714:b0:77b:e7a8:2f66 with SMTP id jg20-20020a170907971400b0077be7a82f66mr13272966ejc.107.1663596637962; Mon, 19 Sep 2022 07:10:37 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-214-223.pool.digikabel.hu. [193.226.214.223]) by smtp.gmail.com with ESMTPSA id lb22-20020a170907785600b0073bdf71995dsm9849951ejc.139.2022.09.19.07.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 07:10:37 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Al Viro , Amir Goldstein , David Howells , Yu-li Lin , Chirantan Ekbote Subject: [PATCH v2 3/8] cachefiles: use tmpfile_open() helper Date: Mon, 19 Sep 2022 16:10:26 +0200 Message-Id: <20220919141031.1834447-4-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919141031.1834447-1-mszeredi@redhat.com> References: <20220919141031.1834447-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Use the tmpfile_open() helper instead of doing tmpfile creation and opening separately. Signed-off-by: Miklos Szeredi --- fs/cachefiles/namei.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index d3a5884fe5c9..44f575328af4 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -451,18 +451,19 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object) const struct cred *saved_cred; struct dentry *fan = volume->fanout[(u8)object->cookie->key_hash]; struct file *file; - struct path path; + struct path path = { .mnt = cache->mnt, .dentry = fan }; uint64_t ni_size; long ret; cachefiles_begin_secure(cache, &saved_cred); - path.mnt = cache->mnt; ret = cachefiles_inject_write_error(); if (ret == 0) { - path.dentry = vfs_tmpfile(&init_user_ns, fan, S_IFREG, O_RDWR); - ret = PTR_ERR_OR_ZERO(path.dentry); + file = tmpfile_open(&init_user_ns, &path, S_IFREG, + O_RDWR | O_LARGEFILE | O_DIRECT, + cache->cache_cred); + ret = PTR_ERR_OR_ZERO(file); } if (ret) { trace_cachefiles_vfs_error(object, d_inode(fan), ret, @@ -471,12 +472,14 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object) cachefiles_io_error_obj(object, "Failed to create tmpfile"); goto err; } + /* From now path refers to the tmpfile */ + path.dentry = file->f_path.dentry; trace_cachefiles_tmpfile(object, d_backing_inode(path.dentry)); ret = -EBUSY; if (!cachefiles_mark_inode_in_use(object, path.dentry)) - goto err_dput; + goto err_fput; ret = cachefiles_ondemand_init_object(object); if (ret < 0) @@ -499,14 +502,6 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object) } } - file = open_with_fake_path(&path, O_RDWR | O_LARGEFILE | O_DIRECT, - d_backing_inode(path.dentry), cache->cache_cred); - ret = PTR_ERR(file); - if (IS_ERR(file)) { - trace_cachefiles_vfs_error(object, d_backing_inode(path.dentry), - ret, cachefiles_trace_open_error); - goto err_unuse; - } ret = -EINVAL; if (unlikely(!file->f_op->read_iter) || unlikely(!file->f_op->write_iter)) { @@ -514,15 +509,14 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object) pr_notice("Cache does not support read_iter and write_iter\n"); goto err_unuse; } - dput(path.dentry); out: cachefiles_end_secure(cache, saved_cred); return file; err_unuse: cachefiles_do_unmark_inode_in_use(object, path.dentry); -err_dput: - dput(path.dentry); +err_fput: + fput(file); err: file = ERR_PTR(ret); goto out; From patchwork Mon Sep 19 14:10:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12980503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C916C6FA8B for ; Mon, 19 Sep 2022 14:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229825AbiISOKx (ORCPT ); Mon, 19 Sep 2022 10:10:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbiISOKq (ORCPT ); Mon, 19 Sep 2022 10:10:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 720FA32060 for ; Mon, 19 Sep 2022 07:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663596642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HtGv9+3gS2D85s/eedKc+SrnAeSzRrunAfJn42YF+SQ=; b=R/wU+UxahGFbSBgRcl0U3kvtrOIpXIBc0RVK1DkCC/5FaLK6uyqvcX7tVcYI8Y0mrhabKU fiFVBGS3vex7OsEMs30mHpUrtqJASmHe0lPCJIS50YeJ1MHmKtO9Y8yVWEUmXNm+etK9Nb BrGKzDGz1+pCfNuivaClN+tGhlPzJCk= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-304-bu10oB5CO0m2WKke6vF-2g-1; Mon, 19 Sep 2022 10:10:41 -0400 X-MC-Unique: bu10oB5CO0m2WKke6vF-2g-1 Received: by mail-ej1-f70.google.com with SMTP id xj11-20020a170906db0b00b0077b6ecb23fcso8757107ejb.5 for ; Mon, 19 Sep 2022 07:10:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=HtGv9+3gS2D85s/eedKc+SrnAeSzRrunAfJn42YF+SQ=; b=6/umAkjfm/+i6JEsl4YYcTYzUu+scsXwiZNbj5ZRk2cd+F0YhQnwfIFjYnGmmM3PK0 5QwvRWoPTHICh1rIyr/vaucww443cf/309stRtMnVZ83rDOsgcpuwI12zaBEQisxc2aE OSdUADMo/gt23YJVt9rkmFuAnLCFPGFK/DUdCfbe1Pjfj1/RAXokKLSftbnKTqZN+ZBU AOElAkMQ7itBrU4gPCuXe1AIVhq5TMCiLTS6Iau9kh74aE8T+xrx/tGz1DtGCUoMOg07 XMZvmFHKMlQvnlbZy8yHmgqLu6/Ck4mAjqrsOBY7lkW6IAmTgykoqQBBlwhLiCf2EdPg oQug== X-Gm-Message-State: ACrzQf1276UbMKnn0La5l1COeP0BAqMd4skueDU94GPUwrGDXAyplswC UfwZqnma7n6VSDLmBht76X0hWLl5UZ7Hqum3ZwZeaL8O4I0h6xZq7vI2MD6o3vFoqa7WxGnit9C 81tZ84AubnqVGj0801lkOH11rroWJbR5bCczbUE3NIsZoq3RkiDLlwAHUX793Ps1OkGNspC9TC8 pzZA== X-Received: by 2002:a50:fe91:0:b0:43d:c97d:1b93 with SMTP id d17-20020a50fe91000000b0043dc97d1b93mr15940168edt.67.1663596639576; Mon, 19 Sep 2022 07:10:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM61DVDd8dZUkVyi6GvPHJ9UUUJbpAWAdYR9a3TMnGr6dfcYTI2lRzC+CeVpgSyx8c/rtDEqFw== X-Received: by 2002:a50:fe91:0:b0:43d:c97d:1b93 with SMTP id d17-20020a50fe91000000b0043dc97d1b93mr15940121edt.67.1663596638998; Mon, 19 Sep 2022 07:10:38 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-214-223.pool.digikabel.hu. [193.226.214.223]) by smtp.gmail.com with ESMTPSA id lb22-20020a170907785600b0073bdf71995dsm9849951ejc.139.2022.09.19.07.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 07:10:38 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Al Viro , Amir Goldstein , David Howells , Yu-li Lin , Chirantan Ekbote Subject: [PATCH v2 4/8] ovl: use tmpfile_open() helper Date: Mon, 19 Sep 2022 16:10:27 +0200 Message-Id: <20220919141031.1834447-5-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919141031.1834447-1-mszeredi@redhat.com> References: <20220919141031.1834447-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org If tmpfile is used for copy up, then use this helper to create the tmpfile and open it at the same time. This will later allow filesystems such as fuse to do this operation atomically. Signed-off-by: Miklos Szeredi --- fs/overlayfs/copy_up.c | 49 ++++++++++++++++++++++------------------ fs/overlayfs/overlayfs.h | 12 ++++++---- fs/overlayfs/super.c | 10 ++++---- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index fdde6c56cc3d..ac087b48b5da 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -194,16 +194,16 @@ static int ovl_copy_fileattr(struct inode *inode, struct path *old, } static int ovl_copy_up_data(struct ovl_fs *ofs, struct path *old, - struct path *new, loff_t len) + struct path *new, struct file *new_file, loff_t len) { struct file *old_file; - struct file *new_file; loff_t old_pos = 0; loff_t new_pos = 0; loff_t cloned; loff_t data_pos = -1; loff_t hole_len; bool skip_hole = false; + bool fput_new = false; int error = 0; if (len == 0) @@ -213,10 +213,13 @@ static int ovl_copy_up_data(struct ovl_fs *ofs, struct path *old, if (IS_ERR(old_file)) return PTR_ERR(old_file); - new_file = ovl_path_open(new, O_LARGEFILE | O_WRONLY); - if (IS_ERR(new_file)) { - error = PTR_ERR(new_file); - goto out_fput; + if (!new_file) { + new_file = ovl_path_open(new, O_LARGEFILE | O_WRONLY); + if (IS_ERR(new_file)) { + error = PTR_ERR(new_file); + goto out_fput; + } + fput_new = true; } /* Try to use clone_file_range to clone up within the same fs */ @@ -285,7 +288,8 @@ static int ovl_copy_up_data(struct ovl_fs *ofs, struct path *old, out: if (!error && ovl_should_sync(ofs)) error = vfs_fsync(new_file, 0); - fput(new_file); + if (fput_new) + fput(new_file); out_fput: fput(old_file); return error; @@ -556,7 +560,8 @@ static int ovl_link_up(struct ovl_copy_up_ctx *c) return err; } -static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp) +static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp, + struct file *tmpfile) { struct ovl_fs *ofs = OVL_FS(c->dentry->d_sb); struct inode *inode = d_inode(c->dentry); @@ -575,7 +580,7 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp) */ if (S_ISREG(c->stat.mode) && !c->metacopy) { ovl_path_lowerdata(c->dentry, &datapath); - err = ovl_copy_up_data(ofs, &datapath, &upperpath, + err = ovl_copy_up_data(ofs, &datapath, &upperpath, tmpfile, c->stat.size); if (err) return err; @@ -688,7 +693,7 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c) if (IS_ERR(temp)) goto unlock; - err = ovl_copy_up_inode(c, temp); + err = ovl_copy_up_inode(c, temp, NULL); if (err) goto cleanup; @@ -732,6 +737,7 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c) struct ovl_fs *ofs = OVL_FS(c->dentry->d_sb); struct inode *udir = d_inode(c->destdir); struct dentry *temp, *upper; + struct file *tmpfile; struct ovl_cu_creds cc; int err; @@ -739,15 +745,16 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c) if (err) return err; - temp = ovl_do_tmpfile(ofs, c->workdir, c->stat.mode); + tmpfile = ovl_do_tmpfile(ofs, c->workdir, c->stat.mode); ovl_revert_cu_creds(&cc); - if (IS_ERR(temp)) - return PTR_ERR(temp); + if (IS_ERR(tmpfile)) + return PTR_ERR(tmpfile); - err = ovl_copy_up_inode(c, temp); + temp = tmpfile->f_path.dentry; + err = ovl_copy_up_inode(c, temp, tmpfile); if (err) - goto out_dput; + goto out_fput; inode_lock_nested(udir, I_MUTEX_PARENT); @@ -761,16 +768,14 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c) inode_unlock(udir); if (err) - goto out_dput; + goto out_fput; if (!c->metacopy) ovl_set_upperdata(d_inode(c->dentry)); - ovl_inode_update(d_inode(c->dentry), temp); + ovl_inode_update(d_inode(c->dentry), dget(temp)); - return 0; - -out_dput: - dput(temp); +out_fput: + fput(tmpfile); return err; } @@ -919,7 +924,7 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c) goto out; } - err = ovl_copy_up_data(ofs, &datapath, &upperpath, c->stat.size); + err = ovl_copy_up_data(ofs, &datapath, &upperpath, NULL, c->stat.size); if (err) goto out_free; diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 87759165d32b..259a6e73d0c4 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -310,14 +310,16 @@ static inline int ovl_do_whiteout(struct ovl_fs *ofs, return err; } -static inline struct dentry *ovl_do_tmpfile(struct ovl_fs *ofs, - struct dentry *dentry, umode_t mode) +static inline struct file *ovl_do_tmpfile(struct ovl_fs *ofs, + struct dentry *dentry, umode_t mode) { - struct dentry *ret = vfs_tmpfile(ovl_upper_mnt_userns(ofs), dentry, mode, 0); - int err = PTR_ERR_OR_ZERO(ret); + struct path path = { .mnt = ovl_upper_mnt(ofs), .dentry = dentry }; + struct file *file = tmpfile_open(ovl_upper_mnt_userns(ofs), &path, mode, + O_LARGEFILE | O_WRONLY, current_cred()); + int err = PTR_ERR_OR_ZERO(file); pr_debug("tmpfile(%pd2, 0%o) = %i\n", dentry, mode, err); - return ret; + return file; } static inline struct dentry *ovl_lookup_upper(struct ovl_fs *ofs, diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index ec746d447f1b..7837223689c1 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "overlayfs.h" MODULE_AUTHOR("Miklos Szeredi "); @@ -1356,7 +1357,8 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs, struct path *workpath) { struct vfsmount *mnt = ovl_upper_mnt(ofs); - struct dentry *temp, *workdir; + struct dentry *workdir; + struct file *tmpfile; bool rename_whiteout; bool d_type; int fh_type; @@ -1392,10 +1394,10 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs, pr_warn("upper fs needs to support d_type.\n"); /* Check if upper/work fs supports O_TMPFILE */ - temp = ovl_do_tmpfile(ofs, ofs->workdir, S_IFREG | 0); - ofs->tmpfile = !IS_ERR(temp); + tmpfile = ovl_do_tmpfile(ofs, ofs->workdir, S_IFREG | 0); + ofs->tmpfile = !IS_ERR(tmpfile); if (ofs->tmpfile) - dput(temp); + fput(tmpfile); else pr_warn("upper fs does not support tmpfile.\n"); From patchwork Mon Sep 19 14:10:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12980504 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAF21C54EE9 for ; Mon, 19 Sep 2022 14:10:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230006AbiISOKy (ORCPT ); Mon, 19 Sep 2022 10:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiISOKr (ORCPT ); Mon, 19 Sep 2022 10:10:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EA6332063 for ; Mon, 19 Sep 2022 07:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663596643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=61fGxMQX0SECJ5OtxS6TsO0S1PrbjcjAwRpThQXXzOs=; b=GbX2kP4mfMmqGLjq2/Iptf1aJJl7MM0WilO8UlIu8y8FsabFjU0y6MuRdfz4/L+zk5kWqp 9IoIIifz6zX967DidP7H2fResfgKkdYdoxWNSabG085/RB1uegN/3S9eqfEwHp2uCvpMBv YVppPAcKEeugfilf7hhlprYBg+Mk0MU= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-267-v4d2ncLHMlu9gCC-ar9J5Q-1; Mon, 19 Sep 2022 10:10:42 -0400 X-MC-Unique: v4d2ncLHMlu9gCC-ar9J5Q-1 Received: by mail-ed1-f72.google.com with SMTP id y14-20020a056402440e00b0044301c7ccd9so20265281eda.19 for ; Mon, 19 Sep 2022 07:10:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=61fGxMQX0SECJ5OtxS6TsO0S1PrbjcjAwRpThQXXzOs=; b=Z35tfrRSDvnxrJQwGFv0Y6ZmFJPTxnL9QYF/a1tiesAl6nD6HzEnz/SKITQ3GVR9Zf V1xI9an2W8P5y56cracC6UMUtGtvDb/wvdv+L6AUrm9T9qQLzM6qohwbS/gm5FI5075p okerkqD8XLCqEZfPUjjLrIgoBBlqCkvzJuLrQw5Hfd7CL6Z1GK/x791PlOfMEqyk8p8u WZi66NKtUsVBjd/q7NZ+w3I2+ZsjVYFnwRgjcr0bHP8HEj7jPTFYnUPQw6LHry/O0/jC slba8+tLtR7hgSgE+bHzkfPDsgx8vB8p3nsi9+pMLRqTr//BQKHXlQpLEOXgBTgLIClM zW8A== X-Gm-Message-State: ACrzQf22PqYdIUGdUBPTzW1gqa5Oa+Skq1wNSeOplnnh6FQl/t42lpmW vBEIG4LAG43ENr1L5UR5uE0FGRbvoMLNtkzQBxo1ttVMIMHPjkvdWXJ8tymsDZg8SUgMVJwwPsu jJ4+Hm73d0y+msulTtdE+jjGTMwhAa18spMMf4pdhbQyJsnpfB0duAFIRGT4otctkDVo6q8Z5DW gNPg== X-Received: by 2002:a05:6402:1655:b0:44e:b208:746d with SMTP id s21-20020a056402165500b0044eb208746dmr16018090edx.229.1663596641004; Mon, 19 Sep 2022 07:10:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ZCYqD3kw8B69W5UngmITdEdOAwVoOp2JGRgF5eyE3NLUUbl52bwI3ECInobDmNk66tIqZlg== X-Received: by 2002:a05:6402:1655:b0:44e:b208:746d with SMTP id s21-20020a056402165500b0044eb208746dmr16018074edx.229.1663596640679; Mon, 19 Sep 2022 07:10:40 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-214-223.pool.digikabel.hu. [193.226.214.223]) by smtp.gmail.com with ESMTPSA id lb22-20020a170907785600b0073bdf71995dsm9849951ejc.139.2022.09.19.07.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 07:10:39 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Al Viro , Amir Goldstein , David Howells , Yu-li Lin , Chirantan Ekbote Subject: [PATCH v2 5/8] vfs: make vfs_tmpfile() static Date: Mon, 19 Sep 2022 16:10:28 +0200 Message-Id: <20220919141031.1834447-6-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919141031.1834447-1-mszeredi@redhat.com> References: <20220919141031.1834447-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org No callers outside of fs/namei.c anymore. Signed-off-by: Miklos Szeredi --- fs/namei.c | 3 +-- include/linux/fs.h | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 5e4a0c59eef6..652d09ae66fb 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3583,7 +3583,7 @@ static int do_open(struct nameidata *nd, * On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply passs init_user_ns. */ -struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, +static struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, struct dentry *dentry, umode_t mode, int open_flag) { struct dentry *child = NULL; @@ -3622,7 +3622,6 @@ struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, dput(child); return ERR_PTR(error); } -EXPORT_SYMBOL(vfs_tmpfile); /** * tmpfile_open - open a tmpfile for kernel internal use diff --git a/include/linux/fs.h b/include/linux/fs.h index 34e7a189565b..a445da4842e0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2004,9 +2004,6 @@ static inline int vfs_whiteout(struct user_namespace *mnt_userns, WHITEOUT_DEV); } -struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, - struct dentry *dentry, umode_t mode, int open_flag); - struct file *tmpfile_open(struct user_namespace *mnt_userns, const struct path *parentpath, umode_t mode, int open_flag, const struct cred *cred); From patchwork Mon Sep 19 14:10:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12980505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77071C6FA8B for ; Mon, 19 Sep 2022 14:10:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbiISOKz (ORCPT ); Mon, 19 Sep 2022 10:10:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbiISOKs (ORCPT ); Mon, 19 Sep 2022 10:10:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B046131DFD for ; Mon, 19 Sep 2022 07:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663596645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A/WZypUOARqjqxBYzDb24XhV4Ramykp+1sRUd+3h/a8=; b=e9J5xCaZby7PUm5YGHU8hv/shIbln7xmss+MTuS3smtZoT+T4PfmFsKWC8PKwqHFaW6y4Y 1T5eWBfYaL1xAr5rri3J/RZckCP9d42ZXkR0zaj4R6Guvk+bq8c9uS1qYelHNaAQkhtC9I RU61wPFoePw0B0ag0LABb/Nk76FhF6E= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-379-FAAyA4FQOVGP7JEOK5wWjg-1; Mon, 19 Sep 2022 10:10:44 -0400 X-MC-Unique: FAAyA4FQOVGP7JEOK5wWjg-1 Received: by mail-ed1-f71.google.com with SMTP id i17-20020a05640242d100b0044f18a5379aso20707811edc.21 for ; Mon, 19 Sep 2022 07:10:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=A/WZypUOARqjqxBYzDb24XhV4Ramykp+1sRUd+3h/a8=; b=qD1jGIW5ngTigKJTUycCQ4zLt5AQTAodo3Rs9pXP3M1t+oqVwgPrRMsG7O/g/tBRSt ERYYnniZ6fRsyO4i1j2b868iznOSXZ6IYzX38aMrdJXWfYkezx1QusSPs+2iiNQkH83D uA+9D2eWip+2UTnNa2pNollnCaCv2vTl1tzWHGTaiPsqKK3KwUAGY/pL1X74nHzWP3ZQ +xGEqzwvBN9lUuz1p8czKcuE5360XCEzYiJbGuyl7DbeJ27D82mwyzU7riVPUEJVK7C4 w9JqPnsl/ARph47VElEiLG/L/OUlX0X5WSc2Z1NIofhSxXLnTjfCg6P0fTztIi2A210P 0brQ== X-Gm-Message-State: ACrzQf0j6Y4G+5NDCx4Amg1R7zvfEoQ3bEtaQtq1LY5ZIU/pZGNCABly EcktnfIhTVd38CCsIhtL7SkhYY5O1CyrCyctzCk8uxhOcZFwd6KXhmvdZCJ6uvLA2qr0bm2pcb7 V3IMfXpX5cGLHXf3A/fECrhdjqHEdoOw/919r4DC/Jeg/Nb4STOmG/GIpc4jfQTzxz+kWz0I81T QJ+g== X-Received: by 2002:a05:6402:274c:b0:44f:334e:1e11 with SMTP id z12-20020a056402274c00b0044f334e1e11mr15772254edd.304.1663596643403; Mon, 19 Sep 2022 07:10:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MpYd68eGk+Y26U6ElFI/IPzwDwqglhFB7YvkhK7G7zqyNgopO7oCdCQgpfWCfhBBq6JGrWQ== X-Received: by 2002:a05:6402:274c:b0:44f:334e:1e11 with SMTP id z12-20020a056402274c00b0044f334e1e11mr15772236edd.304.1663596643155; Mon, 19 Sep 2022 07:10:43 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-214-223.pool.digikabel.hu. [193.226.214.223]) by smtp.gmail.com with ESMTPSA id lb22-20020a170907785600b0073bdf71995dsm9849951ejc.139.2022.09.19.07.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 07:10:42 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Al Viro , Amir Goldstein , David Howells , Yu-li Lin , Chirantan Ekbote Subject: [PATCH v2 6/8] vfs: move open right after ->tmpfile() Date: Mon, 19 Sep 2022 16:10:29 +0200 Message-Id: <20220919141031.1834447-7-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919141031.1834447-1-mszeredi@redhat.com> References: <20220919141031.1834447-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Create a helper finish_open_simple() that opens the file with the original dentry. Handle the error case here as well to simplify callers. Call this helper right after ->tmpfile() is called. Next patch will change the tmpfile API and move this call into tmpfile instances. Signed-off-by: Miklos Szeredi --- fs/namei.c | 65 ++++++++++++++++++++-------------------------- include/linux/fs.h | 9 +++++++ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 652d09ae66fb..eb1e1956450f 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3583,11 +3583,12 @@ static int do_open(struct nameidata *nd, * On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply passs init_user_ns. */ -static struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, - struct dentry *dentry, umode_t mode, int open_flag) +static int vfs_tmpfile(struct user_namespace *mnt_userns, + const struct path *parentpath, + struct file *file, umode_t mode) { - struct dentry *child = NULL; - struct inode *dir = dentry->d_inode; + struct dentry *child; + struct inode *dir = d_inode(parentpath->dentry); struct inode *inode; int error; @@ -3599,28 +3600,34 @@ static struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, if (!dir->i_op->tmpfile) goto out_err; error = -ENOMEM; - child = d_alloc(dentry, &slash_name); + child = d_alloc(parentpath->dentry, &slash_name); if (unlikely(!child)) goto out_err; + file->f_path.mnt = parentpath->mnt; + file->f_path.dentry = child; mode = vfs_prepare_mode(mnt_userns, dir, mode, mode, mode); error = dir->i_op->tmpfile(mnt_userns, dir, child, mode); + error = finish_open_simple(file, error); + dput(child); + if (error) + goto out_err; + error = may_open(mnt_userns, &file->f_path, 0, file->f_flags); if (error) goto out_err; error = -ENOENT; inode = child->d_inode; if (unlikely(!inode)) goto out_err; - if (!(open_flag & O_EXCL)) { + if (!(file->f_flags & O_EXCL)) { spin_lock(&inode->i_lock); inode->i_state |= I_LINKABLE; spin_unlock(&inode->i_lock); } ima_post_create_tmpfile(mnt_userns, inode); - return child; + return 0; out_err: - dput(child); - return ERR_PTR(error); + return error; } /** @@ -3641,25 +3648,15 @@ struct file *tmpfile_open(struct user_namespace *mnt_userns, { struct file *file; int error; - struct path path = { .mnt = parentpath->mnt }; - - path.dentry = vfs_tmpfile(mnt_userns, parentpath->dentry, mode, open_flag); - if (IS_ERR(path.dentry)) - return ERR_CAST(path.dentry); - - error = may_open(mnt_userns, &path, 0, open_flag); - file = ERR_PTR(error); - if (error) - goto out_dput; - - /* - * This relies on the "noaccount" property of fake open, otherwise - * equivalent to dentry_open(). - */ - file = open_with_fake_path(&path, open_flag, d_inode(path.dentry), cred); -out_dput: - dput(path.dentry); + file = alloc_empty_file_noaccount(open_flag, cred); + if (!IS_ERR(file)) { + error = vfs_tmpfile(mnt_userns, parentpath, file, mode); + if (error) { + fput(file); + file = ERR_PTR(error); + } + } return file; } EXPORT_SYMBOL(tmpfile_open); @@ -3669,26 +3666,20 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags, struct file *file) { struct user_namespace *mnt_userns; - struct dentry *child; struct path path; int error = path_lookupat(nd, flags | LOOKUP_DIRECTORY, &path); + if (unlikely(error)) return error; error = mnt_want_write(path.mnt); if (unlikely(error)) goto out; mnt_userns = mnt_user_ns(path.mnt); - child = vfs_tmpfile(mnt_userns, path.dentry, op->mode, op->open_flag); - error = PTR_ERR(child); - if (IS_ERR(child)) + error = vfs_tmpfile(mnt_userns, &path, file, op->mode); + if (error) goto out2; - dput(path.dentry); - path.dentry = child; - audit_inode(nd->name, child, 0); + audit_inode(nd->name, file->f_path.dentry, 0); /* Don't check for other permissions, the inode was just created */ - error = may_open(mnt_userns, &path, 0, op->open_flag); - if (!error) - error = vfs_open(&path, file); out2: mnt_drop_write(path.mnt); out: diff --git a/include/linux/fs.h b/include/linux/fs.h index a445da4842e0..f0d17eefb966 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2780,6 +2780,15 @@ extern int finish_open(struct file *file, struct dentry *dentry, int (*open)(struct inode *, struct file *)); extern int finish_no_open(struct file *file, struct dentry *dentry); +/* Helper for the simple case when original dentry is used */ +static inline int finish_open_simple(struct file *file, int error) +{ + if (error) + return error; + + return finish_open(file, file->f_path.dentry, NULL); +} + /* fs/dcache.c */ extern void __init vfs_caches_init_early(void); extern void __init vfs_caches_init(void); From patchwork Mon Sep 19 14:10:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12980507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C63D3C6FA8B for ; Mon, 19 Sep 2022 14:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbiISOLN (ORCPT ); Mon, 19 Sep 2022 10:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbiISOLK (ORCPT ); Mon, 19 Sep 2022 10:11:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F74831EF4 for ; Mon, 19 Sep 2022 07:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663596648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D8GWN68mp0xnKhyXIjx2aULUMOVtUcygRhxHd/PDryc=; b=UZLVchWmfHRtyKzGjsFEKKVHwH/v6+WUR+8pErJisMVi0dJUDqyK8rK6wW9HaQdPT+LhYT /HFyGjh4VXRvo6BxYw0CXIaL7ORtngfQI3SsO3ywPB3C9dszux+Nm+dwUNTFlrfpzOTLN8 XYBMT1rNDgF7O+jMPxYO+2r9u77+vUs= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-536-sy0OiUdhNq-Fsnylmhc4bQ-1; Mon, 19 Sep 2022 10:10:46 -0400 X-MC-Unique: sy0OiUdhNq-Fsnylmhc4bQ-1 Received: by mail-ed1-f70.google.com with SMTP id r11-20020a05640251cb00b004516feb8c09so17475317edd.10 for ; Mon, 19 Sep 2022 07:10:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=D8GWN68mp0xnKhyXIjx2aULUMOVtUcygRhxHd/PDryc=; b=U5HEnKvqJTsBjMG3R2WXz9w+778DKdg4rKmU5yJHt4CWiTl0QZpHc9MKCu2yOjnEX+ leUA96ClflhZW2mxtYXhbwmTqQtDm6X7FhV28yAbnOgcfVFqrt0KfeOblIVZWWSE0mZM 9SKl7rLHwOmvfNMaIC/p3ensz5YRFbvXn56oxpmU2/1OhMIVEsKQoq3aWhXcR08gyTcM OdRY0Lhy0WNwzEM+itaZnUHJDzJvaIFdVadQ0Gk5SqX+qcKw6UpNjhPL/6XDEkwSs8Iu 6Sk70BTASCLaQTaNbCJzFg7RfZ0sSaHxgzTZ+FQV7yiTTmF59ltcMbiwzu5666QgANox kmaA== X-Gm-Message-State: ACrzQf18b8ddagU14jbT3AzDo3oxcpP2XvvTaqi18noDLxPSNkBEsYPW e8uF0rnjtpvBbQuCAU/um+9fkMzGGU/4a9+Tq1g+E88mCaAjKDTKLokywpF/TeecO0Mnx184cDt y+sqadMylUr9wQ9tbmEGh5nLHx+5k6ixk/QOWmq2efr/3kD6GfGn1RbsGyWXa0fDXTUbzQgSCCj 4Lwg== X-Received: by 2002:a17:906:a219:b0:6e4:86a3:44ea with SMTP id r25-20020a170906a21900b006e486a344eamr13560943ejy.385.1663596644559; Mon, 19 Sep 2022 07:10:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41wDXaA+iOQgG2f7UhAqeOf/8a0vCRa8GCPdq3k/exkrDXx2uywgwqnYDHofnr0uFqj4zrRg== X-Received: by 2002:a17:906:a219:b0:6e4:86a3:44ea with SMTP id r25-20020a170906a21900b006e486a344eamr13560912ejy.385.1663596644145; Mon, 19 Sep 2022 07:10:44 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-214-223.pool.digikabel.hu. [193.226.214.223]) by smtp.gmail.com with ESMTPSA id lb22-20020a170907785600b0073bdf71995dsm9849951ejc.139.2022.09.19.07.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 07:10:43 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Al Viro , Amir Goldstein , David Howells , Yu-li Lin , Chirantan Ekbote Subject: [PATCH v2 7/8] vfs: open inside ->tmpfile() Date: Mon, 19 Sep 2022 16:10:30 +0200 Message-Id: <20220919141031.1834447-8-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919141031.1834447-1-mszeredi@redhat.com> References: <20220919141031.1834447-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is in preparation for adding tmpfile support to fuse, which requires that the tmpfile creation and opening are done as a single operation. Replace the 'struct dentry *' argument of i_op->tmpfile with 'struct file *'. Call finish_open_simple() as the last thing in ->tmpfile() instances (may be omitted in the error case). Change d_tmpfile() argument to 'struct file *' as well to make callers more readable. Signed-off-by: Miklos Szeredi --- fs/bad_inode.c | 2 +- fs/btrfs/inode.c | 8 ++++---- fs/dcache.c | 4 +++- fs/ext2/namei.c | 6 +++--- fs/ext4/namei.c | 6 +++--- fs/f2fs/namei.c | 13 ++++++++----- fs/hugetlbfs/inode.c | 12 +++++++----- fs/minix/namei.c | 6 +++--- fs/namei.c | 3 +-- fs/ramfs/inode.c | 6 +++--- fs/ubifs/dir.c | 7 ++++--- fs/udf/namei.c | 6 +++--- fs/xfs/xfs_iops.c | 16 +++++++++------- include/linux/dcache.h | 3 ++- include/linux/fs.h | 2 +- mm/shmem.c | 6 +++--- 16 files changed, 58 insertions(+), 48 deletions(-) diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 12b8fdcc445b..9d1cde8066cf 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c @@ -147,7 +147,7 @@ static int bad_inode_atomic_open(struct inode *inode, struct dentry *dentry, } static int bad_inode_tmpfile(struct user_namespace *mnt_userns, - struct inode *inode, struct dentry *dentry, + struct inode *inode, struct file *file, umode_t mode) { return -EIO; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 1372210869b1..416373721085 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10168,7 +10168,7 @@ static int btrfs_permission(struct user_namespace *mnt_userns, } static int btrfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, umode_t mode) + struct file *file, umode_t mode) { struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb); struct btrfs_trans_handle *trans; @@ -10176,7 +10176,7 @@ static int btrfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, struct inode *inode; struct btrfs_new_inode_args new_inode_args = { .dir = dir, - .dentry = dentry, + .dentry = file->f_path.dentry, .orphan = true, }; unsigned int trans_num_items; @@ -10213,7 +10213,7 @@ static int btrfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, set_nlink(inode, 1); if (!ret) { - d_tmpfile(dentry, inode); + d_tmpfile(file, inode); unlock_new_inode(inode); mark_inode_dirty(inode); } @@ -10225,7 +10225,7 @@ static int btrfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, out_inode: if (ret) iput(inode); - return ret; + return finish_open_simple(file, ret); } void btrfs_set_range_writeback(struct btrfs_inode *inode, u64 start, u64 end) diff --git a/fs/dcache.c b/fs/dcache.c index bb0c4d0038db..89dc61389102 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -3258,8 +3258,10 @@ void d_genocide(struct dentry *parent) EXPORT_SYMBOL(d_genocide); -void d_tmpfile(struct dentry *dentry, struct inode *inode) +void d_tmpfile(struct file *file, struct inode *inode) { + struct dentry *dentry = file->f_path.dentry; + inode_dec_link_count(inode); BUG_ON(dentry->d_name.name != dentry->d_iname || !hlist_unhashed(&dentry->d_u.d_alias) || diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 5fd9a22d2b70..9125eab85146 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c @@ -120,7 +120,7 @@ static int ext2_create (struct user_namespace * mnt_userns, } static int ext2_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, umode_t mode) + struct file *file, umode_t mode) { struct inode *inode = ext2_new_inode(dir, mode, NULL); if (IS_ERR(inode)) @@ -128,9 +128,9 @@ static int ext2_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, ext2_set_file_ops(inode); mark_inode_dirty(inode); - d_tmpfile(dentry, inode); + d_tmpfile(file, inode); unlock_new_inode(inode); - return 0; + return finish_open_simple(file, 0); } static int ext2_mknod (struct user_namespace * mnt_userns, struct inode * dir, diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 3a31b662f661..9c3fde633a6e 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2849,7 +2849,7 @@ static int ext4_mknod(struct user_namespace *mnt_userns, struct inode *dir, } static int ext4_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, umode_t mode) + struct file *file, umode_t mode) { handle_t *handle; struct inode *inode; @@ -2871,7 +2871,7 @@ static int ext4_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, inode->i_op = &ext4_file_inode_operations; inode->i_fop = &ext4_file_operations; ext4_set_aops(inode); - d_tmpfile(dentry, inode); + d_tmpfile(file, inode); err = ext4_orphan_add(handle, inode); if (err) goto err_unlock_inode; @@ -2882,7 +2882,7 @@ static int ext4_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, ext4_journal_stop(handle); if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) goto retry; - return err; + return finish_open_simple(file, err); err_unlock_inode: ext4_journal_stop(handle); unlock_new_inode(inode); diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index bf00d5057abb..d5065a5af1f8 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -845,7 +845,7 @@ static int f2fs_mknod(struct user_namespace *mnt_userns, struct inode *dir, } static int __f2fs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, umode_t mode, bool is_whiteout, + struct file *file, umode_t mode, bool is_whiteout, struct inode **new_inode) { struct f2fs_sb_info *sbi = F2FS_I_SB(dir); @@ -892,8 +892,8 @@ static int __f2fs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, inode->i_state |= I_LINKABLE; spin_unlock(&inode->i_lock); } else { - if (dentry) - d_tmpfile(dentry, inode); + if (file) + d_tmpfile(file, inode); else f2fs_i_links_write(inode, false); } @@ -915,16 +915,19 @@ static int __f2fs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, } static int f2fs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, umode_t mode) + struct file *file, umode_t mode) { struct f2fs_sb_info *sbi = F2FS_I_SB(dir); + int err; if (unlikely(f2fs_cp_error(sbi))) return -EIO; if (!f2fs_is_checkpoint_ready(sbi)) return -ENOSPC; - return __f2fs_tmpfile(mnt_userns, dir, dentry, mode, false, NULL); + err = __f2fs_tmpfile(mnt_userns, dir, file, mode, false, NULL); + + return finish_open_simple(file, err); } static int f2fs_create_whiteout(struct user_namespace *mnt_userns, diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index f7a5b5124d8a..eb8689c83369 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -889,7 +889,7 @@ static int do_hugetlbfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev, - bool tmpfile) + struct file *tmpfile) { struct inode *inode; int error = -ENOSPC; @@ -898,7 +898,7 @@ static int do_hugetlbfs_mknod(struct inode *dir, if (inode) { dir->i_ctime = dir->i_mtime = current_time(dir); if (tmpfile) { - d_tmpfile(dentry, inode); + d_tmpfile(tmpfile, inode); } else { d_instantiate(dentry, inode); dget(dentry);/* Extra count - pin the dentry in core */ @@ -911,7 +911,7 @@ static int do_hugetlbfs_mknod(struct inode *dir, static int hugetlbfs_mknod(struct user_namespace *mnt_userns, struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { - return do_hugetlbfs_mknod(dir, dentry, mode, dev, false); + return do_hugetlbfs_mknod(dir, dentry, mode, dev, NULL); } static int hugetlbfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir, @@ -932,10 +932,12 @@ static int hugetlbfs_create(struct user_namespace *mnt_userns, } static int hugetlbfs_tmpfile(struct user_namespace *mnt_userns, - struct inode *dir, struct dentry *dentry, + struct inode *dir, struct file *file, umode_t mode) { - return do_hugetlbfs_mknod(dir, dentry, mode | S_IFREG, 0, true); + int err = do_hugetlbfs_mknod(dir, file->f_path.dentry, mode | S_IFREG, 0, file); + + return finish_open_simple(file, err); } static int hugetlbfs_symlink(struct user_namespace *mnt_userns, diff --git a/fs/minix/namei.c b/fs/minix/namei.c index 937fa5fae2b8..8afdc408ca4f 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c @@ -53,16 +53,16 @@ static int minix_mknod(struct user_namespace *mnt_userns, struct inode *dir, } static int minix_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, umode_t mode) + struct file *file, umode_t mode) { int error; struct inode *inode = minix_new_inode(dir, mode, &error); if (inode) { minix_set_inode(inode, 0); mark_inode_dirty(inode); - d_tmpfile(dentry, inode); + d_tmpfile(file, inode); } - return error; + return finish_open_simple(file, error); } static int minix_create(struct user_namespace *mnt_userns, struct inode *dir, diff --git a/fs/namei.c b/fs/namei.c index eb1e1956450f..1548161b563c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3606,8 +3606,7 @@ static int vfs_tmpfile(struct user_namespace *mnt_userns, file->f_path.mnt = parentpath->mnt; file->f_path.dentry = child; mode = vfs_prepare_mode(mnt_userns, dir, mode, mode, mode); - error = dir->i_op->tmpfile(mnt_userns, dir, child, mode); - error = finish_open_simple(file, error); + error = dir->i_op->tmpfile(mnt_userns, dir, file, mode); dput(child); if (error) goto out_err; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index bc66d0173e33..b3257e852820 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -146,15 +146,15 @@ static int ramfs_symlink(struct user_namespace *mnt_userns, struct inode *dir, } static int ramfs_tmpfile(struct user_namespace *mnt_userns, - struct inode *dir, struct dentry *dentry, umode_t mode) + struct inode *dir, struct file *file, umode_t mode) { struct inode *inode; inode = ramfs_get_inode(dir->i_sb, dir, mode, 0); if (!inode) return -ENOSPC; - d_tmpfile(dentry, inode); - return 0; + d_tmpfile(file, inode); + return finish_open_simple(file, 0); } static const struct inode_operations ramfs_dir_inode_operations = { diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 86151889548e..f59acd6a3615 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -424,8 +424,9 @@ static void unlock_2_inodes(struct inode *inode1, struct inode *inode2) } static int ubifs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, umode_t mode) + struct file *file, umode_t mode) { + struct dentry *dentry = file->f_path.dentry; struct inode *inode; struct ubifs_info *c = dir->i_sb->s_fs_info; struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1, @@ -475,7 +476,7 @@ static int ubifs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, mutex_lock(&ui->ui_mutex); insert_inode_hash(inode); - d_tmpfile(dentry, inode); + d_tmpfile(file, inode); ubifs_assert(c, ui->dirty); instantiated = 1; @@ -489,7 +490,7 @@ static int ubifs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, ubifs_release_budget(c, &req); - return 0; + return finish_open_simple(file, 0); out_cancel: unlock_2_inodes(dir, inode); diff --git a/fs/udf/namei.c b/fs/udf/namei.c index b3d5f97f16cd..fb4c30e05245 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -626,7 +626,7 @@ static int udf_create(struct user_namespace *mnt_userns, struct inode *dir, } static int udf_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, umode_t mode) + struct file *file, umode_t mode) { struct inode *inode = udf_new_inode(dir, mode); @@ -640,9 +640,9 @@ static int udf_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, inode->i_op = &udf_file_inode_operations; inode->i_fop = &udf_file_operations; mark_inode_dirty(inode); - d_tmpfile(dentry, inode); + d_tmpfile(file, inode); unlock_new_inode(inode); - return 0; + return finish_open_simple(file, 0); } static int udf_mknod(struct user_namespace *mnt_userns, struct inode *dir, diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 45518b8c613c..764409c466fd 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -167,7 +167,7 @@ xfs_generic_create( struct dentry *dentry, umode_t mode, dev_t rdev, - bool tmpfile) /* unnamed file */ + struct file *tmpfile) /* unnamed file */ { struct inode *inode; struct xfs_inode *ip = NULL; @@ -234,7 +234,7 @@ xfs_generic_create( * d_tmpfile can immediately set it back to zero. */ set_nlink(inode, 1); - d_tmpfile(dentry, inode); + d_tmpfile(tmpfile, inode); } else d_instantiate(dentry, inode); @@ -261,7 +261,7 @@ xfs_vn_mknod( umode_t mode, dev_t rdev) { - return xfs_generic_create(mnt_userns, dir, dentry, mode, rdev, false); + return xfs_generic_create(mnt_userns, dir, dentry, mode, rdev, NULL); } STATIC int @@ -272,7 +272,7 @@ xfs_vn_create( umode_t mode, bool flags) { - return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, false); + return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, NULL); } STATIC int @@ -283,7 +283,7 @@ xfs_vn_mkdir( umode_t mode) { return xfs_generic_create(mnt_userns, dir, dentry, mode | S_IFDIR, 0, - false); + NULL); } STATIC struct dentry * @@ -1080,10 +1080,12 @@ STATIC int xfs_vn_tmpfile( struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, + struct file *file, umode_t mode) { - return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, true); + int err = xfs_generic_create(mnt_userns, dir, file->f_path.dentry, mode, 0, file); + + return finish_open_simple(file, err); } static const struct inode_operations xfs_inode_operations = { diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 92c78ed02b54..bde9f8ff8869 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -16,6 +16,7 @@ #include struct path; +struct file; struct vfsmount; /* @@ -250,7 +251,7 @@ extern struct dentry * d_make_root(struct inode *); /* - the ramfs-type tree */ extern void d_genocide(struct dentry *); -extern void d_tmpfile(struct dentry *, struct inode *); +extern void d_tmpfile(struct file *, struct inode *); extern struct dentry *d_find_alias(struct inode *); extern void d_prune_aliases(struct inode *); diff --git a/include/linux/fs.h b/include/linux/fs.h index f0d17eefb966..e08efecd2644 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2168,7 +2168,7 @@ struct inode_operations { struct file *, unsigned open_flag, umode_t create_mode); int (*tmpfile) (struct user_namespace *, struct inode *, - struct dentry *, umode_t); + struct file *, umode_t); int (*set_acl)(struct user_namespace *, struct inode *, struct posix_acl *, int); int (*fileattr_set)(struct user_namespace *mnt_userns, diff --git a/mm/shmem.c b/mm/shmem.c index 42e5888bf84d..f63c51bc373e 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2912,7 +2912,7 @@ shmem_mknod(struct user_namespace *mnt_userns, struct inode *dir, static int shmem_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, - struct dentry *dentry, umode_t mode) + struct file *file, umode_t mode) { struct inode *inode; int error = -ENOSPC; @@ -2927,9 +2927,9 @@ shmem_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, error = simple_acl_create(dir, inode); if (error) goto out_iput; - d_tmpfile(dentry, inode); + d_tmpfile(file, inode); } - return error; + return finish_open_simple(file, error); out_iput: iput(inode); return error; From patchwork Mon Sep 19 14:10:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12980506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE477ECAAD3 for ; Mon, 19 Sep 2022 14:11:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229846AbiISOLM (ORCPT ); Mon, 19 Sep 2022 10:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbiISOLK (ORCPT ); Mon, 19 Sep 2022 10:11:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37FE031EF9 for ; Mon, 19 Sep 2022 07:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663596649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wGsSwi5yFIWxEALJ9auZ58Wh8GXaKXFvqfjaGSnnGHs=; b=Yn7ykJuyCmfzyrtGGuEPUgweYKlEMpkvwrtC5lfOH+gLVOiSgNMWna5kX9a0QWEqrI19V+ ZVdoWFVD/cqbL282Ak3E2AOjJMN4N0ztOvlE/w7gf9pKPresVu1zAuoD5RxCAf+sOJ+ChI isYuyI8T3Tor4byjy+f5hk31yF/lhjo= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-665-1VWcHAo9NVSdzLktCqM2RA-1; Mon, 19 Sep 2022 10:10:47 -0400 X-MC-Unique: 1VWcHAo9NVSdzLktCqM2RA-1 Received: by mail-ed1-f72.google.com with SMTP id dz21-20020a0564021d5500b0045217702048so14884316edb.5 for ; Mon, 19 Sep 2022 07:10:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=wGsSwi5yFIWxEALJ9auZ58Wh8GXaKXFvqfjaGSnnGHs=; b=7JUyCzAyWk2iobRwZA3z0yFh9S3aQwN6cTkPFjro/CkJ1gAQH+DN8RKmhm5lk/8Jro BZc6sOXCxJ0ZeKf0+eR5+tmrwx5mJFk6h83Yz9bJjrenIBj/ZIMWO8daUbr0yMWlTWO7 Twbg4r6os1R8H174lNcwGxRMQ6USvhrw6Gjz4/b3KimFwW6DElCyaqIFto5S9Ek2QrBn wlie4OB7dWXmmpcWLzcaJM4H2FIYh5NOBF+BULmXxWs6wYT2sYzhke6WsbERh60A4aXX hto3XsgQsUNe3gQ2+e0uDY1pCtK0Ww2OaDHVAxvK+Vl5mOScf5bnEqNIwA+anCNLGP16 FiPA== X-Gm-Message-State: ACrzQf3s33qHbf1995csN5lqyy6EMhMpwsGUvWAyWgM+IZdE7YIFB8U8 hKipl0zb4vNbMuisMi5F+ln/ChPjqDF8c7wsBK7SEtNdFwC3vx0qWCLKVt1S2vIPamXC5z6hVD/ gO7LpRbiSVu42kocCwo84cQAp52yaxhfnpGngTSQOIHpSzFYi8KBlDNRSQ7y/5cCCFXYXtKHkPc dOJA== X-Received: by 2002:a17:907:320b:b0:780:280:7b72 with SMTP id xg11-20020a170907320b00b0078002807b72mr13612402ejb.146.1663596646541; Mon, 19 Sep 2022 07:10:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5DFGni3UCjR9m4/XHAIxZjoMSqSM8V0Q8vdUp0LLKhI13xy312vPXfJgSKG9i9RyI69u09gw== X-Received: by 2002:a17:907:320b:b0:780:280:7b72 with SMTP id xg11-20020a170907320b00b0078002807b72mr13612385ejb.146.1663596646263; Mon, 19 Sep 2022 07:10:46 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-214-223.pool.digikabel.hu. [193.226.214.223]) by smtp.gmail.com with ESMTPSA id lb22-20020a170907785600b0073bdf71995dsm9849951ejc.139.2022.09.19.07.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 07:10:45 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: Al Viro , Amir Goldstein , David Howells , Yu-li Lin , Chirantan Ekbote Subject: [PATCH v2 8/8] fuse: implement ->tmpfile() Date: Mon, 19 Sep 2022 16:10:31 +0200 Message-Id: <20220919141031.1834447-9-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919141031.1834447-1-mszeredi@redhat.com> References: <20220919141031.1834447-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is basically equivalent to the FUSE_CREATE operation which creates and opens a regular file. Add a new FUSE_TMPFILE operation, otherwise just reuse the protocol and the code for FUSE_CREATE. Signed-off-by: Miklos Szeredi --- fs/fuse/dir.c | 25 ++++++++++++++++++++++--- fs/fuse/fuse_i.h | 3 +++ include/uapi/linux/fuse.h | 6 +++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index b585b04e815e..01b2d5c5a64a 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -529,7 +529,7 @@ static int get_security_context(struct dentry *entry, umode_t mode, */ static int fuse_create_open(struct inode *dir, struct dentry *entry, struct file *file, unsigned int flags, - umode_t mode) + umode_t mode, u32 opcode) { int err; struct inode *inode; @@ -573,7 +573,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, inarg.open_flags |= FUSE_OPEN_KILL_SUIDGID; } - args.opcode = FUSE_CREATE; + args.opcode = opcode; args.nodeid = get_node_id(dir); args.in_numargs = 2; args.in_args[0].size = sizeof(inarg); @@ -676,7 +676,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, if (fc->no_create) goto mknod; - err = fuse_create_open(dir, entry, file, flags, mode); + err = fuse_create_open(dir, entry, file, flags, mode, FUSE_CREATE); if (err == -ENOSYS) { fc->no_create = 1; goto mknod; @@ -802,6 +802,24 @@ static int fuse_create(struct user_namespace *mnt_userns, struct inode *dir, return fuse_mknod(&init_user_ns, dir, entry, mode, 0); } +static int fuse_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, + struct file *file, umode_t mode) +{ + struct fuse_conn *fc = get_fuse_conn(dir); + int err; + + if (fc->no_tmpfile) + goto no_tmpfile; + + err = fuse_create_open(dir, file->f_path.dentry, file, file->f_flags, mode, FUSE_TMPFILE); + if (err == -ENOSYS) { + fc->no_tmpfile = 1; +no_tmpfile: + err = -EOPNOTSUPP; + } + return err; +} + static int fuse_mkdir(struct user_namespace *mnt_userns, struct inode *dir, struct dentry *entry, umode_t mode) { @@ -1913,6 +1931,7 @@ static const struct inode_operations fuse_dir_inode_operations = { .setattr = fuse_setattr, .create = fuse_create, .atomic_open = fuse_atomic_open, + .tmpfile = fuse_tmpfile, .mknod = fuse_mknod, .permission = fuse_permission, .getattr = fuse_getattr, diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 488b460e046f..98a9cf531873 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -784,6 +784,9 @@ struct fuse_conn { /* Does the filesystem support per inode DAX? */ unsigned int inode_dax:1; + /* Is tmpfile not implemented by fs? */ + unsigned int no_tmpfile:1; + /** The number of requests waiting for completion */ atomic_t num_waiting; diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index d6ccee961891..76ee8f9e024a 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -194,6 +194,9 @@ * - add FUSE_SECURITY_CTX init flag * - add security context to create, mkdir, symlink, and mknod requests * - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX + * + * 7.37 + * - add FUSE_TMPFILE */ #ifndef _LINUX_FUSE_H @@ -229,7 +232,7 @@ #define FUSE_KERNEL_VERSION 7 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 36 +#define FUSE_KERNEL_MINOR_VERSION 37 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 @@ -537,6 +540,7 @@ enum fuse_opcode { FUSE_SETUPMAPPING = 48, FUSE_REMOVEMAPPING = 49, FUSE_SYNCFS = 50, + FUSE_TMPFILE = 51, /* CUSE specific operations */ CUSE_INIT = 4096,