Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2677326pxa; Mon, 17 Aug 2020 16:20:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymxR4mUD/WCcb+M0SNRUuSWRznJjl0hSXhDrbx0sDhNitaJH+zeQ+V80/2XgAWEQVxaOim X-Received: by 2002:a17:906:e218:: with SMTP id gf24mr18166908ejb.469.1597706458631; Mon, 17 Aug 2020 16:20:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597706458; cv=none; d=google.com; s=arc-20160816; b=uV99UggnmcaXWGqLjjm/zeDDaJ6Kn17H8L0OoXFckyV4r57zQV9ZBuH1ai/NICu84b SREuiqwcb63SzEP3dwlOPF/lqX8IJxxcIkRF6ShD4gZE8IWoSFBc/9J0R/mX5HvbMuGN auF789OOUArHv3qftXkikkuSOVXEyiUgwW658CSqx1ngu1fPsnLgHgMOUFl0DcUhlndm 5CCCk+5sA/Ipj0L/mV+4MuPzHlQPPiOi/7EaJ2cOB7sfgYR1Rz6XdMA4oZWsMUwm7RJ5 XGoz+8ojJ0OG09VrEEV5g12EFrrufW8KHE+Utu6is1DPCpAKGbJjJay25kNFWzxD3YUh zVHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=XvinLvXljx2WCWOLfsl8KyTKTWSHd9dGuB08l9Nyscw=; b=qFgYQY3sgimBxZaQ5cPL/hbkj5Do7isLUFQ4K4TFP6E+OyvFbAtRQAxc4hdwySJGsP xUREeK+TpkpUouAVA0YYuXKLS75QWwJMFuO38Of40gKTd56krHYr9izREQognb87FV0D Qpb29xcS0oaA4s8p4WpUvgyuPYEs50O6SQuxRat1Os8bX4q1msIe0ptKA9mMjAfnbeBP aVD1WQEzcsRuq5iS2z6W73SYY4EaVbFPfxdXDU8Dj1vK4LqWJRdnypeuzFI8VN84/l5A MM1QbCBmKteE4TfOWcuhja52TYTIrGS8H+LxACMVVINGE3zIx2x2TS46Qvf3uwpZYuYA Nu8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i20si11866333edj.383.2020.08.17.16.20.34; Mon, 17 Aug 2020 16:20:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730422AbgHQWNB (ORCPT + 99 others); Mon, 17 Aug 2020 18:13:01 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:47196 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730260AbgHQWLv (ORCPT ); Mon, 17 Aug 2020 18:11:51 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1k7nM5-004wAW-N5; Mon, 17 Aug 2020 16:11:49 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.int.ebiederm.org) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1k7nKi-0004PB-Ca; Mon, 17 Aug 2020 16:10:25 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, criu@openvz.org, bpf@vger.kernel.org, Linus Torvalds , Alexander Viro , Christian Brauner , Oleg Nesterov , Cyrill Gorcunov , Jann Horn , Kees Cook , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jeff Layton , Miklos Szeredi , Matthew Wilcox , "J. Bruce Fields" , Matthew Wilcox , Trond Myklebust , Chris Wright , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , "Eric W. Biederman" Date: Mon, 17 Aug 2020 17:04:21 -0500 Message-Id: <20200817220425.9389-13-ebiederm@xmission.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <87ft8l6ic3.fsf@x220.int.ebiederm.org> References: <87ft8l6ic3.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-XM-SPF: eid=1k7nKi-0004PB-Ca;;;mid=<20200817220425.9389-13-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/ngUYSxGxun5r6v9Ze6FBWcJvkSSWh6d0= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: * X-Spam-Status: No, score=1.3 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMNoVowels autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 0; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: ; sa07 0; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 645 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 11 (1.7%), b_tie_ro: 9 (1.5%), parse: 1.34 (0.2%), extract_message_metadata: 25 (3.8%), get_uri_detail_list: 2.8 (0.4%), tests_pri_-1000: 18 (2.8%), tests_pri_-950: 1.67 (0.3%), tests_pri_-900: 1.32 (0.2%), tests_pri_-90: 277 (42.9%), check_bayes: 275 (42.6%), b_tokenize: 11 (1.8%), b_tok_get_all: 9 (1.4%), b_comp_prob: 3.0 (0.5%), b_tok_touch_all: 247 (38.3%), b_finish: 1.22 (0.2%), tests_pri_0: 255 (39.5%), check_dkim_signature: 1.06 (0.2%), check_dkim_adsp: 2.3 (0.4%), poll_dns_idle: 0.56 (0.1%), tests_pri_10: 2.2 (0.3%), tests_pri_500: 49 (7.6%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 13/17] file: Remove get_files_struct X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When discussing[1] exec and posix file locks it was realized that none of the callers of get_files_struct fundamentally needed to call get_files_struct, and that by switching them to helper functions instead it will both simplify their code and remove unnecessary increments of files_struct.count. Those unnecessary increments can result in exec unnecessarily unsharing files_struct which breaking posix locks, and it can result in fget_light having to fallback to fget reducing system performance. Now that get_files_struct has no more users and can not cause the problems for posix file locking and fget_light remove get_files_struct so that it does not gain any new users. [1] https://lkml.kernel.org/r/20180915160423.GA31461@redhat.com Suggested-by: Oleg Nesterov Signed-off-by: "Eric W. Biederman" --- fs/file.c | 13 ------------- include/linux/fdtable.h | 1 - 2 files changed, 14 deletions(-) diff --git a/fs/file.c b/fs/file.c index 88f9f78869f8..605e756f3c63 100644 --- a/fs/file.c +++ b/fs/file.c @@ -410,19 +410,6 @@ static struct fdtable *close_files(struct files_struct * files) return fdt; } -struct files_struct *get_files_struct(struct task_struct *task) -{ - struct files_struct *files; - - task_lock(task); - files = task->files; - if (files) - atomic_inc(&files->count); - task_unlock(task); - - return files; -} - void put_files_struct(struct files_struct *files) { if (atomic_dec_and_test(&files->count)) { diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index a3a054084f49..8c4bc6aa19c9 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -108,7 +108,6 @@ struct file *fnext_task(struct task_struct *task, unsigned int *fd); struct task_struct; -struct files_struct *get_files_struct(struct task_struct *); void put_files_struct(struct files_struct *fs); int unshare_files(void); struct files_struct *dup_fd(struct files_struct *, unsigned, int *) __latent_entropy; -- 2.25.0