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 872F4EB64D7 for ; Tue, 20 Jun 2023 17:05:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230404AbjFTRF2 (ORCPT ); Tue, 20 Jun 2023 13:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjFTRF0 (ORCPT ); Tue, 20 Jun 2023 13:05:26 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAEFB10D0; Tue, 20 Jun 2023 10:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=7t0yCtklu7dcKbRDLlcm/F8iSnhf9vNHGW7kJ98+ijg=; b=JCLIgzHF25CkwrefXaVLUdy0uy iuWI9Lxna/dv3i02JTOmbhRFm2Ou8dZGbJStETfXOyITasuUNJ/SNXkOr4iA4fJ53Ah3elhKtodun j6Qe72jCN5UPnEPI/8xcfE9ewUlma+JtYW70K4uh97wc6TXEW1UCPOSmPcQ0S83Kyjr7CADu1/9fu JrJAUOIhcKxjzJkeVDDyyxcNjEikiUXJG3FK2LlvDtJir+r+41+Y01h6k5UB0YF8riRcMdW2GJC2z QjR3s2BUDmGSEsk5889V1JnlvOCLz/noACPY6fhQNL8Z8qiLlIjl9uzIoN0qxe7tP+028bc/443Vf lHJXj8Rw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qBen9-00DKRn-QG; Tue, 20 Jun 2023 17:05:19 +0000 Date: Tue, 20 Jun 2023 18:05:19 +0100 From: Matthew Wilcox To: stsp Cc: Jeff Layton , linux-kernel@vger.kernel.org, Chuck Lever , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 2/3] fd/locks: allow get the lock owner by F_OFD_GETLK Message-ID: References: <5f644a24-90b5-a02f-b593-49336e8e0f5a@yandex.ru> <2eb8566726e95a01536b61a3b8d0343379092b94.camel@kernel.org> <08612562-d2d7-a931-0c40-c401fff772c7@yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <08612562-d2d7-a931-0c40-c401fff772c7@yandex.ru> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Jun 20, 2023 at 08:45:21PM +0500, stsp wrote: > > 20.06.2023 19:36, Matthew Wilcox пишет: > > On Tue, Jun 20, 2023 at 06:47:31PM +0500, stsp wrote: > > > 20.06.2023 18:46, Matthew Wilcox пишет: > > > > On Tue, Jun 20, 2023 at 06:39:07PM +0500, stsp wrote: > > > > > Though it will, for sure, represent the > > > > > task that _owns_ the lock. > > > > No, it *DOESN'T*. I can open a file, SCM_RIGHTS pass it to another task > > > > and then exit. Now the only owner of that lock is the recipient ... > > > Won't I get the recipient's pid in an > > > l_pid then? > > You snipped the part where I pointed out that at times there can be > > _no_ task that owns it. open a fd, set the lock, pass the fd to another > > task, exit. until that task calls recvmsg(), no task owns it. > Hmm, interesting case. > So at least it seems if recipient also exits, > then the untransferred fd gets closed. yes, pretty sure this is done by garbage collection in the unix socket handling code, though i've never looked at it. it's done that way because annoying people can do things like open two sockets and send the fd of each to the other, then exit. > Does this mean, by any chance, that the > recipient actually owns an fd before > recvmsg() is done? no, it's not in their fd table. they don't own it.