From patchwork Fri Sep 16 19:44:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12978807 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 ECBF5ECAAD8 for ; Fri, 16 Sep 2022 19:44:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230280AbiIPToY (ORCPT ); Fri, 16 Sep 2022 15:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbiIPToW (ORCPT ); Fri, 16 Sep 2022 15:44:22 -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 30B0FB40F4 for ; Fri, 16 Sep 2022 12:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663357460; 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; bh=PzsiJLh4qivuvaD01T8k0cktWemsb5i0yo5HxUE+jT4=; b=iPyfuAIcTuU3EQkpzMbafwEIQ5wTzrfFmQysrtTCq4WDV0hDBAwXDqfmysO467WiQVKCi5 TH3QtIHz58u/Li88z2rdXz3+XiMPxuHGONaTFtzaKiaNJLpYQb55cCG7asY8OpjFFOUzbS 4P9TehpUwuQoMckHsr3jjMu/YyemNBw= 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-494--B0G-7oLM7qFdljfAPsTHw-1; Fri, 16 Sep 2022 15:44:19 -0400 X-MC-Unique: -B0G-7oLM7qFdljfAPsTHw-1 Received: by mail-ed1-f71.google.com with SMTP id m3-20020a056402430300b004512f6268dbso14856856edc.23 for ; Fri, 16 Sep 2022 12:44:19 -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:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=PzsiJLh4qivuvaD01T8k0cktWemsb5i0yo5HxUE+jT4=; b=bvmNC2uXp0qunyQ4m8Km9QbmvXOro4BN2qHAmnjB2cvlEugBWz9qSV9VE3ERjBD8A8 7OOcIP2jwHcqSqWsiS1g62KZuN6J/F/4EHh9UR1kd9IusjI9Fz2M3h4NAKlZ0QP/wWeU K0RHDTf9AQtpGmNfT0y76br+q5hOpt1fj4V1ucJibmt6M26oogHGU6oeogMdqX+8O1ou firwVyu0rYxdRBzHkUZEs3QdIgJ9r46wsaSd6ZKpxg4pFWPJaxu0xJkV67t2kOGSq8T8 KemlObmUvrbtANJghV7hh8iay6/kCrUXiWgIoJ2iehVjSLr55a5pVwgjnxycs+5CNdot 52RQ== X-Gm-Message-State: ACrzQf1ssfyK5YK4feV8WSaLIidAX9ejUEQHLQBoguT1QHMpj/3f5N3u qHFawAp3vOCCzhfrbWbmz5R2t4XtsxPqrJs+bDQrJCErGxVQFGQAZbrm261Cv4yDZuOB1WHGNb4 6wT2JU0m0Rrv3sGAx4jTQRbDsS3kVKGSA47+8aoLswReUzFUwfsm0RsUwbbCWwYomQhTLZhUdpb fiAw== X-Received: by 2002:a05:6402:5488:b0:443:39c5:5347 with SMTP id fg8-20020a056402548800b0044339c55347mr5331247edb.204.1663357457894; Fri, 16 Sep 2022 12:44:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7lpPgPBrZ7yRkhF8x7hAC4HtGKse5Ni+xK2oD4tG1gGBDrSQZh9GLa8EMdojYr2nbOnGmpQA== X-Received: by 2002:a05:6402:5488:b0:443:39c5:5347 with SMTP id fg8-20020a056402548800b0044339c55347mr5331227edb.204.1663357457638; Fri, 16 Sep 2022 12:44:17 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-212-116.pool.digikabel.hu. [193.226.212.116]) by smtp.gmail.com with ESMTPSA id r17-20020a17090609d100b0077ce503bd77sm8348592eje.129.2022.09.16.12.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:44:17 -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 1/8] cachefiles: tmpfile error handling cleanup Date: Fri, 16 Sep 2022 21:44:09 +0200 Message-Id: <20220916194416.1657716-1-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 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 Fri Sep 16 19:44:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12978808 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 DFD72C6FA82 for ; Fri, 16 Sep 2022 19:44:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbiIPToY (ORCPT ); Fri, 16 Sep 2022 15:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbiIPToX (ORCPT ); Fri, 16 Sep 2022 15:44:23 -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 7BE3AB5168 for ; Fri, 16 Sep 2022 12:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663357461; 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=tDvv+QvG1dG0+OfJSXyJZ9PeJhhYUW8AHlr5Rmz0DZA=; b=GZ1p+RqW1j4YzNwb23K0+11HLQaiLC5jH5Eh/tU+mpQH4ccFJKibsZ9Fknyuc27hRjFqj8 BsbRBNeuULAaHaxwlzP0ZYJhlAMqQbiRQD7IFDFJ3WhSveYKPQUGo2t0ZkX/nHmtvIDqdE 71MXt656Fcty63VwyEKbFM/Zuf1x27Y= 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-543-c2IA7UcpP_KmQvA1HFpVng-1; Fri, 16 Sep 2022 15:44:20 -0400 X-MC-Unique: c2IA7UcpP_KmQvA1HFpVng-1 Received: by mail-ed1-f71.google.com with SMTP id f10-20020a0564021e8a00b00451be6582d5so11751101edf.15 for ; Fri, 16 Sep 2022 12:44:20 -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=tDvv+QvG1dG0+OfJSXyJZ9PeJhhYUW8AHlr5Rmz0DZA=; b=45MKHgq/QuJQ4Ad0TPKFne2yvXbMBpWIVdz1XEVtSOkgLvyaQ0GPZ7gX0m1IJSavoX GY+6LNV3PlQScKox5Q6thsNcbAeztHdBF4N0PgPwvvCYQ1GgXjKZmxQZJOMZwQHcKbt5 Ay834uJaV5X4gof2tmN0e7eCbrRsRuph7TKK/2c1Qep+tES8pBE6w5nAAiYm+bHLke1n MBNrPDl0jn0HomfnuC8D+5J41jhqfQRtWiw/3VUhP53+PW5X8L47E2rvLR+U5Mp9etiP 1GkkoT0EMrDqT28+ntr37SOVnBkggv+uwziwNoldUMtR2XCFDyxGHRFpVuqIVqxZFU0m RCzg== X-Gm-Message-State: ACrzQf3+4z4Xstjd/V71hADpX0Yqqg1JfwO3/kYnEgx3e97g/oj0DJqi hchXLcPxDbVDp+ISLLdYCmsblYyqNBRViOKkFRal1BYmY2/+AdPROS9bf1jjUB2g2VkIjhNhxBn OkUnUgI3LSDfEfo8CqTyyLGaSUpayi6AvlDYkFCwDeZcmoidxaLhYrGQneOz4hBYV7NdxbXl9em fK6A== X-Received: by 2002:a17:906:591:b0:73d:c3ef:84ae with SMTP id 17-20020a170906059100b0073dc3ef84aemr4621619ejn.155.1663357458907; Fri, 16 Sep 2022 12:44:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BISLmeCqoctbJXtmKqdcTmws/gbheUbEF5ZcSJoFeXgKA+iDz6GQptGzMF66OLuDpVzDUJg== X-Received: by 2002:a17:906:591:b0:73d:c3ef:84ae with SMTP id 17-20020a170906059100b0073dc3ef84aemr4621606ejn.155.1663357458647; Fri, 16 Sep 2022 12:44:18 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-212-116.pool.digikabel.hu. [193.226.212.116]) by smtp.gmail.com with ESMTPSA id r17-20020a17090609d100b0077ce503bd77sm8348592eje.129.2022.09.16.12.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:44:18 -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 2/8] vfs: add tmpfile_open() helper Date: Fri, 16 Sep 2022 21:44:10 +0200 Message-Id: <20220916194416.1657716-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220916194416.1657716-1-mszeredi@redhat.com> References: <20220916194416.1657716-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 | 43 +++++++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 4 ++++ 2 files changed, 47 insertions(+) diff --git a/fs/namei.c b/fs/namei.c index 53b4bc094db2..078ecd88f016 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3624,6 +3624,49 @@ 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 Fri Sep 16 19:44:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12978809 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 72767C6FA8B for ; Fri, 16 Sep 2022 19:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbiIPTo0 (ORCPT ); Fri, 16 Sep 2022 15:44:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbiIPToX (ORCPT ); Fri, 16 Sep 2022 15:44:23 -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 210DBB40F4 for ; Fri, 16 Sep 2022 12:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663357462; 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=RhJj8DXi9bfpSJjoFEOuasvgtddJJX/UrdUZmsymQCvg1kPtwewKjGXX+ThUWVdbkpFdIi ZKZTZqsJaBJMPrWXLPbqh+YGlgFHpzMRxRwJsTgKwkm+32BLq/zBN60nWviRnx+UBVi7eW 3IUDRuYBB/VCN+kHT8tyaBcU+Rs8KeQ= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-570-fJJp4ytXM_WMLTMWc_pMJw-1; Fri, 16 Sep 2022 15:44:21 -0400 X-MC-Unique: fJJp4ytXM_WMLTMWc_pMJw-1 Received: by mail-ej1-f69.google.com with SMTP id qa33-20020a17090786a100b0077a69976d24so8694188ejc.7 for ; Fri, 16 Sep 2022 12:44:20 -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=SqgZ8pfjq35SN0Ate46SbkbZFi6EFpnMFDP4H/tHACAY6iVQeGuty9RvxaE0Nm+PSu Bp1FSRCsP1OEijK1qUsjpsZg02XeFCZl4HHeloEtYhfh6LicuEjHcN27ZzYi/HW7nD4X vdocB2qZ5JUCHe/NdyUZd4kX2obhterh8XfxtsRV7N3yjlyFc7n4S35QLW9DY0xT+wan tXPj1osKEpNebvI2biqXwDYoz4kPP++B9l2kAH2qxTlg3UPCDkxvphBZ46zC+atKq1v4 dgse7v9fxYuMcJDkJCBcPFtUvVFYdeKtOnhgOR8+2JcKB0aRHCLywUrwT8BewsHEsDbL ZcTA== X-Gm-Message-State: ACrzQf1KYIj+IxBvNq7QsLWDW6+7b/+Ua3HSjAsGmGgdO5pCNeoYQLq5 5/ic7bpP4WiCaR6kWSx4o6xiQe0YVXwHiqQIwTEUwmSTezbsg9k1Ok/nr/HSAF9u8nmPPeecZVJ 1cU4ywyzvQB9qgQq5QQBjsVSkTVf0mD0M0ll5xCIZVAywczPEqkh9sbpT5iBvJg+gePgyMaS48J aVLQ== X-Received: by 2002:a05:6402:4150:b0:44a:ec16:def4 with SMTP id x16-20020a056402415000b0044aec16def4mr5270388eda.21.1663357459848; Fri, 16 Sep 2022 12:44:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Qc0qV0zLQ3LBk0Ml3fEK9PsWdt4VgNc7Vz9c/dRs5RTZarGFttSj96CLSMlGRiJ/3JEnGvg== X-Received: by 2002:a05:6402:4150:b0:44a:ec16:def4 with SMTP id x16-20020a056402415000b0044aec16def4mr5270372eda.21.1663357459615; Fri, 16 Sep 2022 12:44:19 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-212-116.pool.digikabel.hu. [193.226.212.116]) by smtp.gmail.com with ESMTPSA id r17-20020a17090609d100b0077ce503bd77sm8348592eje.129.2022.09.16.12.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:44:19 -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 3/8] cachefiles: use tmpfile_open() helper Date: Fri, 16 Sep 2022 21:44:11 +0200 Message-Id: <20220916194416.1657716-3-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220916194416.1657716-1-mszeredi@redhat.com> References: <20220916194416.1657716-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 Fri Sep 16 19:44:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12978810 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 725AAECAAA1 for ; Fri, 16 Sep 2022 19:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230354AbiIPTo2 (ORCPT ); Fri, 16 Sep 2022 15:44:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbiIPToZ (ORCPT ); Fri, 16 Sep 2022 15:44:25 -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 828CFB40F4 for ; Fri, 16 Sep 2022 12:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663357463; 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=PXhEMQLCSQ4wR2c04dJCjkzQur62vMJiTtAbcdXYOYbjryhhbGTWbikzXKFi8+EnVnK4hU 2df26kjjAD9ZoU8A6bOH3b2W7xgiZXUYb6LZXvvYlMbFLnuGZ0vI6HqnZJMBJKPgmGS6F3 yx1JtSpu5r2ZFAgBAEV5JDtZrr82Q/o= 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-557-AGXwXaCDMzedLyfrfh2AHw-1; Fri, 16 Sep 2022 15:44:22 -0400 X-MC-Unique: AGXwXaCDMzedLyfrfh2AHw-1 Received: by mail-ed1-f69.google.com with SMTP id b16-20020a056402279000b0044f1102e6e2so16017887ede.20 for ; Fri, 16 Sep 2022 12:44:22 -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=mdWKb+NyxmOaa+d67g4Wi0y7YCtqb7lnn6WPhksd2jSnErpeAjBqWTTAFOXfSmNGA2 6Tr/qE28FPyIYqCZvtxhuzi13IhbVOz+JAP3gt60Cpu1ZFjGUI/DsOImN+HMn0pAFSR3 HbsD5MDMqLyyoorZxgjKm3qmAuvAcy3NtgB5lYVbhL5oDewHceC1n5grNDs8lAh+jIDz 3lHN6JdLTT/R5F2hN2sd4th/MzjtNDxgEWO/1htODFXazu3PB+fJOpU6BcNmH2VF2Of5 q6cgQNLZATAAnZAelpFYUFcG5rt0Lguu5BKV9NwOjCpa3Wr6EMnCvIPtvcakCqah53HE 7ffQ== X-Gm-Message-State: ACrzQf1qhADoFjlBcqbitAyereKVmaQuqjJfpfurb23c/GvS33XhyP9g SrUrU51Xc18dPZ9JSxuKStBihMs1OWDQlkV/pYu+JDjSvw3HetQTfyc7S+900OqNAIFSBhaT5ki iprUwcRd2HdxVOKLaqKm5soOil+QwRO+QaxV1fbWAyT6FisSi+Ne7f2lg6OHmR9URJqY+Oxqei+ 6Xog== X-Received: by 2002:a50:9344:0:b0:448:ce76:7c81 with SMTP id n4-20020a509344000000b00448ce767c81mr5201208eda.187.1663357460943; Fri, 16 Sep 2022 12:44:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7smLlIvtvwLuxHIUQyb+Y6uBHP/Kwyb6ZM6CD+o7xabWguhegBV2tr9caWuG4TcpSb99JUJA== X-Received: by 2002:a50:9344:0:b0:448:ce76:7c81 with SMTP id n4-20020a509344000000b00448ce767c81mr5201188eda.187.1663357460673; Fri, 16 Sep 2022 12:44:20 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-212-116.pool.digikabel.hu. [193.226.212.116]) by smtp.gmail.com with ESMTPSA id r17-20020a17090609d100b0077ce503bd77sm8348592eje.129.2022.09.16.12.44.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:44:20 -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 4/8] ovl: use tmpfile_open() helper Date: Fri, 16 Sep 2022 21:44:12 +0200 Message-Id: <20220916194416.1657716-4-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220916194416.1657716-1-mszeredi@redhat.com> References: <20220916194416.1657716-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 Fri Sep 16 19:44:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12978811 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 51A12C6FA82 for ; Fri, 16 Sep 2022 19:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbiIPTob (ORCPT ); Fri, 16 Sep 2022 15:44:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbiIPToZ (ORCPT ); Fri, 16 Sep 2022 15:44:25 -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 2EF0CB531B for ; Fri, 16 Sep 2022 12:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663357464; 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=qiTxfVmHh638eW+FNltRgNbHhvM4aqPe5D02hCK21mY=; b=diRxohcOiyW3Ch/ApkjxDpT/SUs+hVbD3vUhSPOC5sS+LFDRMlntMa1wzl288KhDxlk2N1 MZdMav2y4m9sO56XaNCTS9OzCj0X0EodMPDa5CpRFWVr5uOjB2IePrus+w3xhy4+pmHPy+ wZGC07t4PzG97zD7/WHKRH5DRcjhg30= 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-634-qDYRGYO6OMe07pXNi4NhDg-1; Fri, 16 Sep 2022 15:44:23 -0400 X-MC-Unique: qDYRGYO6OMe07pXNi4NhDg-1 Received: by mail-ed1-f70.google.com with SMTP id y14-20020a056402440e00b0044301c7ccd9so15591348eda.19 for ; Fri, 16 Sep 2022 12:44:23 -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=qiTxfVmHh638eW+FNltRgNbHhvM4aqPe5D02hCK21mY=; b=OkRXaU2E3v8yA4w4Pamp+8nMfhWRCNMCzarpOb8KvczAD3vQjcbonKrYhZ9amJrEhF 3B5b/ri2Ub7NZffFkK1/1pV/SSC2nc8F4YDjeH75tNDgajEKN/dw6ikYJ/pzugAmLWoj wVZLovpW1qAYs6PyaFtomPBNptEhvyWYm1Pke7b9Y+W1y0GR7B4aAiL2axHlmgxPJUZI DKM7sbli3WerYENr9lUsWbuRVDvPNd7iQdWjFbCgkKJONzdyKySKu9Xo6k0Oo07LoCyb rIjHp9GM50rg83BK8X2ZwX5Qnnk2WC/pC5RFVDowasBxRxmYy6sxi7ehKVmCV6C2r3x5 +XLg== X-Gm-Message-State: ACrzQf2TuekC5IoQyThc9axnD6GC9kMRffAsWXPiG7RPWwVfo2kROjvU LFeTGgOf+TvTRWEsBxB1kEL7TK6dI/BWrp3fvTr9uw6bXE4U4ygJZK9kXQOIgt0NwPVbDu5faGa 0hKyFXXd5EBvDw5Uum4Jrt6gfa6Vs/tcQhNWHU8jfs2jD1Jdyk+krq6v8mpE8TpljSkcCFSHi94 NvUA== X-Received: by 2002:a17:906:5a6b:b0:73c:c9ee:8b5c with SMTP id my43-20020a1709065a6b00b0073cc9ee8b5cmr4508023ejc.310.1663357462048; Fri, 16 Sep 2022 12:44:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM55mDTxkaKUHdR6D1Pi3gbJRPbkhJWhHX34ejxsxg+4gk9mKAcFDBcXyodBmW7L9tUJ/fC7/g== X-Received: by 2002:a17:906:5a6b:b0:73c:c9ee:8b5c with SMTP id my43-20020a1709065a6b00b0073cc9ee8b5cmr4508007ejc.310.1663357461774; Fri, 16 Sep 2022 12:44:21 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-212-116.pool.digikabel.hu. [193.226.212.116]) by smtp.gmail.com with ESMTPSA id r17-20020a17090609d100b0077ce503bd77sm8348592eje.129.2022.09.16.12.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:44:21 -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 5/8] vfs: make vfs_tmpfile() static Date: Fri, 16 Sep 2022 21:44:13 +0200 Message-Id: <20220916194416.1657716-5-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220916194416.1657716-1-mszeredi@redhat.com> References: <20220916194416.1657716-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 078ecd88f016..eacaf9ccbaa6 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); /** 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 Fri Sep 16 19:44:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12978812 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 C3492ECAAD8 for ; Fri, 16 Sep 2022 19:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbiIPTog (ORCPT ); Fri, 16 Sep 2022 15:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbiIPTo2 (ORCPT ); Fri, 16 Sep 2022 15:44:28 -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 4F3B21C9 for ; Fri, 16 Sep 2022 12:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663357465; 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=VvSsjYeeLNFAKYPpqwAj5u+RJ7WyP2tyCxzAOfIw+lg=; b=NK2IV06MFnT7OEbBQT5yQBjUhDJowEHPhdm47iCjeZl5q3voicrZZzLkwZBx6MRAoKKYf6 bt1tvsoB7SzJeHSj7jGpB5IXHXvT0UHegdwAx4UMDWIormGaPj4lGEtX31Izx6DuaYpcSH 6n+66FhM0MCecU8sQt0lpbWlDMCm0XA= 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-640-4mfwCDCmPAKeH5-09D7XlA-1; Fri, 16 Sep 2022 15:44:24 -0400 X-MC-Unique: 4mfwCDCmPAKeH5-09D7XlA-1 Received: by mail-ed1-f71.google.com with SMTP id b16-20020a056402279000b0044f1102e6e2so16017927ede.20 for ; Fri, 16 Sep 2022 12:44:24 -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=VvSsjYeeLNFAKYPpqwAj5u+RJ7WyP2tyCxzAOfIw+lg=; b=24/QjdaDl1K8VxvFSbeEDfNgqVuaOd0RHlMHSCC7IuX3TMkDPMSuwAuKvmuPxP5sI5 0SVoYfegq4Z8JG7IJhkpjnQ6FgUHrYYgizcQbc2HrClD2oFCi+l3e3r+XVDSDCQq9Ub0 46psDbOdOCRq5UaVGbvdqMhUeUntoMsGAnyPJ5ggWwmY3T3wXev4OIeqboBCVCZEIX7H upCxeainWonkpLaI1uVKcrMDBSPeUAPoNeS2g1NhO8wyalz1uqEwVkXvaPa491kllSL8 ujn487QBfaAyyxqsk0AnEX67v+5fpKrRdhmLqA3pDzX4WGO1p0pPopWX5pQA0IvTs5uQ 3z1g== X-Gm-Message-State: ACrzQf2vPORm/m759WvU8juAS06hs+uBuK6D5NBBY6oyMk8p8k2TwdzQ pGs6dcpGKzMRS5+UFxTHIP+oQ9F9abqkvtXwEktBqZOr7irUrJNe6Gy5+DEsNJc+24sfCdp7wEn +W+tOI9+Mm+jmHKv6otW8K7ReIW191xa6reUBzxpgTyPG4bfcZaxTJVwDtQkXcMSM2SPZFygFDN JNyg== X-Received: by 2002:a17:907:6093:b0:780:7671:2c97 with SMTP id ht19-20020a170907609300b0078076712c97mr4600703ejc.8.1663357463057; Fri, 16 Sep 2022 12:44:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5XmATNampbtfxyNSOTdK++04hRvOjrqT+i4Gqtk1HPZrzlL6kc3k9z0nIoRXlN/LqVuZ7wUA== X-Received: by 2002:a17:907:6093:b0:780:7671:2c97 with SMTP id ht19-20020a170907609300b0078076712c97mr4600689ejc.8.1663357462816; Fri, 16 Sep 2022 12:44:22 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-212-116.pool.digikabel.hu. [193.226.212.116]) by smtp.gmail.com with ESMTPSA id r17-20020a17090609d100b0077ce503bd77sm8348592eje.129.2022.09.16.12.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:44:22 -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 6/8] vfs: move open right after ->tmpfile() Date: Fri, 16 Sep 2022 21:44:14 +0200 Message-Id: <20220916194416.1657716-6-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220916194416.1657716-1-mszeredi@redhat.com> References: <20220916194416.1657716-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Create a helper finish_tmpfile() that opens a file after the tmpfile creation is done. 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 ++++++++++++++++++++-------------------------- fs/open.c | 11 ++++++++ include/linux/fs.h | 1 + 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index eacaf9ccbaa6..22353853651b 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_tmpfile(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; } @@ -3642,25 +3649,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); @@ -3671,26 +3668,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/fs/open.c b/fs/open.c index 8a813fa5ca56..90ff9d4c0d81 100644 --- a/fs/open.c +++ b/fs/open.c @@ -975,6 +975,17 @@ int finish_open(struct file *file, struct dentry *dentry, } EXPORT_SYMBOL(finish_open); +int finish_tmpfile(struct file *file, int error) +{ + WARN_ON(file->f_mode & FMODE_OPENED); + + if (error) + return error; + + return do_dentry_open(file, d_inode(file->f_path.dentry), NULL); +} +EXPORT_SYMBOL(finish_tmpfile); + /** * finish_no_open - finish ->atomic_open() without opening the file * diff --git a/include/linux/fs.h b/include/linux/fs.h index a445da4842e0..8d0e11ba930c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2778,6 +2778,7 @@ extern void putname(struct filename *name); extern int finish_open(struct file *file, struct dentry *dentry, int (*open)(struct inode *, struct file *)); +extern int finish_tmpfile(struct file *file, int error); extern int finish_no_open(struct file *file, struct dentry *dentry); /* fs/dcache.c */ From patchwork Fri Sep 16 19:44:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12978814 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 8DF59ECAAA1 for ; Fri, 16 Sep 2022 19:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230361AbiIPTot (ORCPT ); Fri, 16 Sep 2022 15:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbiIPToc (ORCPT ); Fri, 16 Sep 2022 15:44:32 -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 2A866273E for ; Fri, 16 Sep 2022 12:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663357467; 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=XsyPbYZS0A5noaUdUtF/Gzc0bJhimEZvGbDruBvT6Dc=; b=ERX6B0URroVWx5DjuApxs8vLcDUIhG6yZ24/12aU65bQppycF5Kb8JemC0sHpsKFY74fud W1MHnWlnMH0pBmTNNPBe61KFLtC+Ox4c+fFRwZ7/G71zOxt9mD+eA0oLwoIFCwLY5N5hmy iiq0VTBbP90CLRpB8u4DH32EcQRieWo= 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-615-d9MRy3ADPTaqvOvRuykHsw-1; Fri, 16 Sep 2022 15:44:26 -0400 X-MC-Unique: d9MRy3ADPTaqvOvRuykHsw-1 Received: by mail-ed1-f71.google.com with SMTP id s17-20020a056402521100b004511c8d59e3so15311726edd.11 for ; Fri, 16 Sep 2022 12:44:25 -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=XsyPbYZS0A5noaUdUtF/Gzc0bJhimEZvGbDruBvT6Dc=; b=66wHTwQCf8ibB+pY3BAdq7cRUpqzWmscNp5xWJwAlhgWohb4mHSA8czseO9GjJO2tI nuy2a8rldY8VjC9GkxxBWuTm25QPghHF7mfMzQT58gLTVJFfbwQtHsALwIiFOlOvXrBh PSy2RbBG4cq/PWxt57TVgcFgv0jrL/wXAl1OwY1UbhYuamuTHXwzZqvjiZsZzVfPgUHM cEW2XdaOfM/T1SxR0NKwDrnP9YpR4Rus9n/EDgSoIerHUh51wWxPDt+IWOu12lMRu9Pa cCcMfUfDidI9LjQsg6VSA/vaWWauJUGXJ6z4EjjrsZeQ74un7Royopi+V5BggjTUSetE 1y3w== X-Gm-Message-State: ACrzQf0SkLMtO4Mj9GuW3NIGWPyg6HdQz659v++eIGocaBS5i+Vau4gK 6GQDVE/gDLTnNggQqP+JmbksnwF7V1JGt9tQtziUzgzlu/9/jcpEwm6V7wP+lvVJmiclyyOJyAh 9VUvYrdFVF3A925UgdBFIWASBvNjBvZ2IUJTaoD4IDEFxIINcAZg16a6aGN6XKnITnUicnYGni7 q+ig== X-Received: by 2002:a17:907:60d3:b0:77e:5e9b:8ec with SMTP id hv19-20020a17090760d300b0077e5e9b08ecmr4616412ejc.640.1663357464153; Fri, 16 Sep 2022 12:44:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6lyCajnovQYrHafaCtuP/k4ghHB8zZAKPujzEoR+RGICEH4TTkiQ9EUiYQnuhbn9+/oTLoDg== X-Received: by 2002:a17:907:60d3:b0:77e:5e9b:8ec with SMTP id hv19-20020a17090760d300b0077e5e9b08ecmr4616393ejc.640.1663357463804; Fri, 16 Sep 2022 12:44:23 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-212-116.pool.digikabel.hu. [193.226.212.116]) by smtp.gmail.com with ESMTPSA id r17-20020a17090609d100b0077ce503bd77sm8348592eje.129.2022.09.16.12.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:44:23 -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 7/8] vfs: open inside ->tmpfile() Date: Fri, 16 Sep 2022 21:44:15 +0200 Message-Id: <20220916194416.1657716-7-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220916194416.1657716-1-mszeredi@redhat.com> References: <20220916194416.1657716-1-mszeredi@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Replace the 'struct dentry *' argument of i_op->tmpfile with 'struct file *'. Call finish_open() 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 Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot --- 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 | 2 +- include/linux/fs.h | 2 +- mm/shmem.c | 6 +++--- 16 files changed, 57 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..ceac5aa9a1ed 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_tmpfile(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..3f53353adb95 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_tmpfile(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..9250fa174a54 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_tmpfile(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..460a056efa82 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_tmpfile(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..bb207560ef68 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_tmpfile(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..fc7d2a6b42d0 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_tmpfile(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 22353853651b..e7e7e1af4835 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_tmpfile(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..dcd8c3b72d33 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_tmpfile(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..63473638456e 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_tmpfile(file, 0); out_cancel: unlock_2_inodes(dir, inode); diff --git a/fs/udf/namei.c b/fs/udf/namei.c index b3d5f97f16cd..6ab0f44a7abf 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_tmpfile(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..8c0671a58bf2 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_tmpfile(file, err); } static const struct inode_operations xfs_inode_operations = { diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 92c78ed02b54..450b933f2bc7 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -250,7 +250,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 8d0e11ba930c..0979b0e5b9f6 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..d504fb4eaa4c 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_tmpfile(file, error); out_iput: iput(inode); return error; From patchwork Fri Sep 16 19:44:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 12978813 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 8B5D1ECAAA1 for ; Fri, 16 Sep 2022 19:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230359AbiIPTos (ORCPT ); Fri, 16 Sep 2022 15:44:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbiIPToc (ORCPT ); Fri, 16 Sep 2022 15:44:32 -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 1C2972726 for ; Fri, 16 Sep 2022 12:44:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663357467; 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=HD7KR6+sxxBe7YuSrx5YnWX6Fh7WUze0jOyqukw05LPyWPzN+1zVGlco9yEoQ37CkpTSd5 DA6bqw4i6D/Pp8qv1FFfkHqdjXHsnN3fT7pqxYiiOmC1xee4NbHS3LEYgtcTfOohsp9gCi VIWOKw8WLAwBpeuOKSxnErGYU2zyWi8= 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-673-bfvVcPazMXeBiIVEe3BWkw-1; Fri, 16 Sep 2022 15:44:26 -0400 X-MC-Unique: bfvVcPazMXeBiIVEe3BWkw-1 Received: by mail-ed1-f70.google.com with SMTP id b16-20020a056402279000b0044f1102e6e2so16017967ede.20 for ; Fri, 16 Sep 2022 12:44:25 -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=VT4gmuVzkqrVbnOPDj1mXV2nQFu5sfwogQm/sW4dLEUxU1uWqIDP2toHwTTip2OGqQ HwxgLUWl49UFJEbkT08Ng1yzmy/B+SO4GB5O3znK+9MagY+Hgc/hOyDI69q35HQg1QQZ Kb2oL5kENSUoIPnBMjTvgkbyspH8xIpLVGvQ0AplDTKjveYWNu3/i8Zou2oPrAfB/XNj wdU3EqnKBcQMsQWBoh7J5la6vTHNm3rREtJ5IEkeCi1XBR6W3P62I4s0bUMWg/EfHQeE 23DrYip3fxj8IDvtDUw1CwEZ7KsV63tXpJj2CJr5xclEn3Jcu4wQ97t0zHDnQ+zQqOQ0 jvdA== X-Gm-Message-State: ACrzQf0vx4FSbKx1hu5N1L5bYN5GIpK7X8FOugLFQDcOKwQ2zGVrPedx AAZVg3+yEx3ykRqZmR00SCbQJIBeIMUr8lAqO1G5faWGafKN6cITQTPoFbMqydiLSFMXk7mNd6n IIusI4uW8aYILUgA5lW15V06C0s3N2vIlZj6PjfoNfnOE6ppArWj0+XHIaKMVftZByepKxYdgHs nGEQ== X-Received: by 2002:a17:907:a05:b0:77b:b538:6476 with SMTP id bb5-20020a1709070a0500b0077bb5386476mr4727469ejc.324.1663357464726; Fri, 16 Sep 2022 12:44:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6706RdDg8hjkySYUg8qtiFYAIOJ+3XqjS2406aPkJa6bnCHLmDVB/6hsk97L7uGZ2y4JFkkg== X-Received: by 2002:a17:907:a05:b0:77b:b538:6476 with SMTP id bb5-20020a1709070a0500b0077bb5386476mr4727456ejc.324.1663357464505; Fri, 16 Sep 2022 12:44:24 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (193-226-212-116.pool.digikabel.hu. [193.226.212.116]) by smtp.gmail.com with ESMTPSA id r17-20020a17090609d100b0077ce503bd77sm8348592eje.129.2022.09.16.12.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 12:44:24 -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 8/8] fuse: implement ->tmpfile() Date: Fri, 16 Sep 2022 21:44:16 +0200 Message-Id: <20220916194416.1657716-8-mszeredi@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220916194416.1657716-1-mszeredi@redhat.com> References: <20220916194416.1657716-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,