Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7665440rwd; Tue, 20 Jun 2023 04:42:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4AHrwzoUwyxko5fSG9QMwhgIh9c5cxViZ92yIy6vebYk7/N0aelzjTct+goFKaZBMzNEbT X-Received: by 2002:a05:6808:1cb:b0:3a0:3e86:3c with SMTP id x11-20020a05680801cb00b003a03e86003cmr851164oic.56.1687261377788; Tue, 20 Jun 2023 04:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687261377; cv=none; d=google.com; s=arc-20160816; b=Vsm4cJIGv4jaITnFhGQd/77wgVnThSoE5wIOi4rAMrKXTMYcuoq9mldJCtA6eIHM5Y xLo+udfz9Z8G3uvSfejfbVIMDXqy8kTfkET/LmqcDUm+vVvjrariQ8l9LiBEbQJkv2HC WsDclPQTIVtKlml5/EOx9EauhJPoubZyLGr5RcKMhAV8idThLEFCpVd4bQKzCWf78gYA dPtr3h4aLP0ocjoQTYK5NsgC4Ql5377L0gm1dBxBJ4rbHPMIvobo+eQJNUfv5y1Up0lh mwiSxHU0DMqWVsbMVuXWonXanCQcIjgqGeowKLHagjaObXpsGqRMZjYlzBUfGbmmEn8N qMtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=7ElQhIPcUWc62CESzMTHtuqKCCz3j5Ffj0RphlMWSu4=; b=DgrGFtghwYjp5jcJiN0TsWW8FuA3aNd66GXdyttreY/NCbFcREOU8qM46vKvYghH56 lVLeHCGplFBp1RmwkaKi7Q7JUOPiTvQ8vTdGFhNyW4cXdlGuJIha+bKf5xmioWvFb2aA S0hIT3CM7OKtjJgERXEUPtysEpkef7WyxqWhAqxT9lTTv5J7cUcL/KIrYIX2U3YMNqIS GrmI7MvVHTiX2a4gz8kGav/MCnXPBOJF/7omINaOmIYV+eXgYATFvLhLRETDvnQeCTbU sFlz/xCfIeb+P9EVmVKpEOkvUDM4uAOc+uvkj3L5xCnjjOu4QmZ3q3zHT7gSjqRXvd2H Jnmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lAQamsTg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r20-20020a17090b051400b002597c3244c5si1685231pjz.80.2023.06.20.04.42.46; Tue, 20 Jun 2023 04:42:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lAQamsTg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232582AbjFTLMU (ORCPT + 99 others); Tue, 20 Jun 2023 07:12:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232430AbjFTLMR (ORCPT ); Tue, 20 Jun 2023 07:12:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A7FA10FE; Tue, 20 Jun 2023 04:12:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 80C26611E2; Tue, 20 Jun 2023 11:12:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D894C433C0; Tue, 20 Jun 2023 11:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687259533; bh=48Q1ZvZWks9PL/vJ+2ghQX3YFsGy4B0LOKhH2s8OAiY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=lAQamsTgFEzaPXSFzQljTEmdNDn4UuRICLZgEEuVC3CBhxynrKaamZgCDbzFRpUg1 l7uUSdesVHquPyMRFYlV4RrZPDg0HLcXcGB/KyRtN44+N/JnFLZe5fz3BUJTPVVaz/ 9RY+X7oe9yci2dZNFdQVmFh5tOwd8Yn/gJU+7NjBYUCY6hboCYQZixQoJNNLtwAoLp +SPB8AmPCh+e2KBcQHmxg6EqsrNaN9hFMSlyws67yrSQO54bb97TFhP3KX4DmEZB7i r3/W0HIGggtrHAyEH7Uphw3glax5kLduey7UaXSYp4y20jZqU0ko9mql/5TZPTo71G oqhsbtPmlFdQA== Message-ID: Subject: Re: [PATCH 2/3] fd/locks: allow get the lock owner by F_OFD_GETLK From: Jeff Layton To: stsp , linux-kernel@vger.kernel.org Cc: Chuck Lever , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org Date: Tue, 20 Jun 2023 07:12:12 -0400 In-Reply-To: References: <20230620095507.2677463-1-stsp2@yandex.ru> <20230620095507.2677463-3-stsp2@yandex.ru> <5728ebda22a723b0eb209ae078e8f132d7b4ac7b.camel@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.3 (3.48.3-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2023-06-20 at 15:57 +0500, stsp wrote: > Hello, >=20 > 20.06.2023 15:51, Jeff Layton =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > > On Tue, 2023-06-20 at 14:55 +0500, Stas Sergeev wrote: > > > Currently F_OFD_GETLK sets the pid of the lock owner to -1. > > > Remove such behavior to allow getting the proper owner's pid. > > > This may be helpful when you want to send some message (like SIGKILL) > > > to the offending locker. > > >=20 > > > Signed-off-by: Stas Sergeev > > >=20 > > > CC: Jeff Layton > > > CC: Chuck Lever > > > CC: Alexander Viro > > > CC: Christian Brauner > > > CC: linux-fsdevel@vger.kernel.org > > > CC: linux-kernel@vger.kernel.org > > >=20 > > > --- > > > fs/locks.c | 2 -- > > > 1 file changed, 2 deletions(-) > > >=20 > > > diff --git a/fs/locks.c b/fs/locks.c > > > index 210766007e63..ee265e166542 100644 > > > --- a/fs/locks.c > > > +++ b/fs/locks.c > > > @@ -2158,8 +2158,6 @@ static pid_t locks_translate_pid(struct file_lo= ck *fl, struct pid_namespace *ns) > > > pid_t vnr; > > > struct pid *pid; > > > =20 > > > - if (IS_OFDLCK(fl)) > > > - return -1; > > > if (IS_REMOTELCK(fl)) > > > return fl->fl_pid; > > > /* > > NACK on this one. > >=20 > > OFD locks are not owned by processes. They are owned by the file > > description (hence the name). Because of this, returning a pid here is > > wrong. >=20 > But fd is owned by a process. No, it isn't. fd's can be handed off between processes via unix descriptors. Multithreaded processes are also a bit of a gray area here: Suppose I open a file and set an OFD lock on it in one task, and then let that task exit while the file is still open. What should l_pid say in that case? > PID has a meaning, you can send SIGKILL > to the returned PID, and the lock is clear. > Was there any reason to hide the PID at > a first place? >=20 Yes, because OFD locks are not tied to a pid in the same way that traditional POSIX locks are. >=20 > > This precedent comes from BSD, where flock() and POSIX locks can > > conflict. BSD returns -1 for the pid if you call F_GETLK on a file > > locked with flock(). Since OFD locks have similar ownership semantics t= o > > flock() locks, we use the same convention here. > OK if you insist I can drop this one and > search the PID by some other means. > Just a bit unsure what makes it so important > to overwrite the potentially useful info > with -1. >=20 > So in case you insist on that, then should > I send a v2 or can you just drop the patch > yourself? --=20 Jeff Layton