Received: by 2002:ac0:adb4:0:0:0:0:0 with SMTP id o49-v6csp6259imb; Tue, 10 Jul 2018 19:28:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf91J9uoF3yd2e5gk/0zC5bJPOJi02Hk4h9kJ8vy0jFJOV3SiPUp98lhnlEs6MGxlTOQ5pO X-Received: by 2002:a17:902:b612:: with SMTP id b18-v6mr26652050pls.131.1531276080688; Tue, 10 Jul 2018 19:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531276080; cv=none; d=google.com; s=arc-20160816; b=XZeV3oiWCxOEGigxZAlzf0YsTG5cQXKXtVBrfaHIBGReJOZwOr9WkdeTqrw/IfTTyY 0Nqqge+DuDE9sMNMI5llwN7bKheb01a7C3tbwhuElf2II5i7sG1elTmOv7xr9hR/3Drx C8BRenfLnbH9Xr79YSHN2W3FgbzZwul5tu6wD/9Tc6gtAsJGY1UvaFhdHD5xlyLZsrX1 mD+uyU6Y+/rke1/hZhG6zqFDqOyOmOfJ6jeCiUO8yMnXTjOd7+YNOFJsAoaWj65vAKza DU4aqh3gORsEmXuBxp33/3hSm73GGsDrZ3AtN8IKnqbYMjnpO9QVAhbxSQEBn0ABjfYj cz9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=R4961NIx8ZJqsRB2A1tWscRyWIFaMcVlDEBBIwvtuMc=; b=Dy3/M2b2YGKJWNlsmMcY2SFoyJr8Y287BeIzIGIXbZbYqjT6uXM56aJUPAAZP3vTYo 9hpYbAHVOeTcTMnktTl9aZyK/iuT4aswOs0jWMPwa931wnGf/dkcnA5AhwxHOeP/1VPB DZvYrrt0OxuzGw4xYi8SxNJ1iuN7LPixMVbDzInn1FBeQV6s09yj9njeq/t3bf9bayd6 hIeCcmGIQ/5C/SU+Eh2pRmtSM4j1uKshU7LDlGYSYMWUMAyxOwGgoS0WnPArs3KE1SNd 0bNvRADOGU+7mp4Vv++u3uSbewkg15E529x/3g7b7RanKfPoUP86clgLLeA6VR5v/eGX 22xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a67-v6si19381766pfb.348.2018.07.10.19.27.45; Tue, 10 Jul 2018 19:28:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732867AbeGKC1Y (ORCPT + 99 others); Tue, 10 Jul 2018 22:27:24 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:45556 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732380AbeGKCYE (ORCPT ); Tue, 10 Jul 2018 22:24:04 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fd4lb-0003If-EC; Wed, 11 Jul 2018 02:22:07 +0000 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Miklos Szeredi Subject: [RFC][PATCH 13/42] introduce FMODE_OPENED Date: Wed, 11 Jul 2018 03:21:37 +0100 Message-Id: <20180711022206.12571-13-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180711022206.12571-1-viro@ZenIV.linux.org.uk> References: <20180711021136.GN30522@ZenIV.linux.org.uk> <20180711022206.12571-1-viro@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro basically, "is that instance set up enough for regular fput(), or do we want put_filp() for that one". NOTE: the only alloc_file() caller that could be followed by put_filp() is in arch/ia64/kernel/perfmon.c, which is (Kconfig-level) broken. Signed-off-by: Al Viro --- fs/file_table.c | 2 +- fs/open.c | 3 ++- include/linux/fs.h | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/file_table.c b/fs/file_table.c index d7a03a47b702..eaee481295de 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -174,7 +174,7 @@ struct file *alloc_file(const struct path *path, fmode_t mode, if ((mode & FMODE_WRITE) && likely(fop->write || fop->write_iter)) mode |= FMODE_CAN_WRITE; - file->f_mode = mode; + file->f_mode = mode | FMODE_OPENED; file->f_op = fop; if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) i_readcount_inc(path->dentry->d_inode); diff --git a/fs/open.c b/fs/open.c index 008a65e82de5..ce092dda5472 100644 --- a/fs/open.c +++ b/fs/open.c @@ -752,7 +752,7 @@ static int do_dentry_open(struct file *f, f->f_wb_err = filemap_sample_wb_err(f->f_mapping); if (unlikely(f->f_flags & O_PATH)) { - f->f_mode = FMODE_PATH; + f->f_mode = FMODE_PATH | FMODE_OPENED; f->f_op = &empty_fops; return 0; } @@ -794,6 +794,7 @@ static int do_dentry_open(struct file *f, if (error) goto cleanup_all; } + f->f_mode |= FMODE_OPENED; if ((f->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) i_readcount_inc(inode); if ((f->f_mode & FMODE_READ) && diff --git a/include/linux/fs.h b/include/linux/fs.h index c4ca4c9c1130..05f34726e29c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -148,6 +148,8 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, /* Has write method(s) */ #define FMODE_CAN_WRITE ((__force fmode_t)0x40000) +#define FMODE_OPENED ((__force fmode_t)0x80000) + /* File was opened by fanotify and shouldn't generate fanotify events */ #define FMODE_NONOTIFY ((__force fmode_t)0x4000000) -- 2.11.0