From mboxrd@z Thu Jan 1 00:00:00 1970 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 6E5C6EB64D7 for ; Tue, 20 Jun 2023 10:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232442AbjFTK5v (ORCPT ); Tue, 20 Jun 2023 06:57:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232458AbjFTK5n (ORCPT ); Tue, 20 Jun 2023 06:57:43 -0400 Received: from forward101b.mail.yandex.net (forward101b.mail.yandex.net [178.154.239.148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D591510E2; Tue, 20 Jun 2023 03:57:37 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1e2b:0:640:94b5:0]) by forward101b.mail.yandex.net (Yandex) with ESMTP id 332E36012D; Tue, 20 Jun 2023 13:57:27 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id Ove6axoDbKo0-nCAOC5kc; Tue, 20 Jun 2023 13:57:26 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1687258646; bh=8FUU/Xa/yU6MIGBp4GSl/zvrLBpWLS521oJYuRHSseE=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=xFE/ov3F6+ItKmJ6eOk67Vb1CbEyk+vE9zyZrtnnNVF1WxL0IKQoKeteIuvNBtACA FY4NmEVVZahjsVl9v/Tx47AqBadSyoNOn6Sk+pzn1qd321IrrDRfAr0bhs7GRKd+S7 pCj/UFepciTUNyFi5wHraMfy1IDZiJKaaBvbaeDI= Authentication-Results: mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: Date: Tue, 20 Jun 2023 15:57:23 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 2/3] fd/locks: allow get the lock owner by F_OFD_GETLK Content-Language: en-US To: Jeff Layton , linux-kernel@vger.kernel.org Cc: Chuck Lever , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org References: <20230620095507.2677463-1-stsp2@yandex.ru> <20230620095507.2677463-3-stsp2@yandex.ru> <5728ebda22a723b0eb209ae078e8f132d7b4ac7b.camel@kernel.org> From: stsp In-Reply-To: <5728ebda22a723b0eb209ae078e8f132d7b4ac7b.camel@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Hello, 20.06.2023 15:51, Jeff Layton пишет: > 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. >> >> Signed-off-by: Stas Sergeev >> >> CC: Jeff Layton >> CC: Chuck Lever >> CC: Alexander Viro >> CC: Christian Brauner >> CC: linux-fsdevel@vger.kernel.org >> CC: linux-kernel@vger.kernel.org >> >> --- >> fs/locks.c | 2 -- >> 1 file changed, 2 deletions(-) >> >> 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_lock *fl, struct pid_namespace *ns) >> pid_t vnr; >> struct pid *pid; >> >> - if (IS_OFDLCK(fl)) >> - return -1; >> if (IS_REMOTELCK(fl)) >> return fl->fl_pid; >> /* > NACK on this one. > > 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. But fd is owned by a process. 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? > 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 to > 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. So in case you insist on that, then should I send a v2 or can you just drop the patch yourself?