Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8122922rwd; Tue, 20 Jun 2023 10:25:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/JafFYPNY7xzytM09V0QWTkBaLLuKzxDn4ddKhvPh325Gk9pZmIR0SonexN43jQdpCmX7 X-Received: by 2002:a05:6a20:3944:b0:121:d0be:1b36 with SMTP id r4-20020a056a20394400b00121d0be1b36mr4375291pzg.26.1687281935500; Tue, 20 Jun 2023 10:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687281935; cv=none; d=google.com; s=arc-20160816; b=cjyBA6j33XUHRVnZ9L6YHxSCrpu0/DZf5+vYJDH6ulqHhnVuGeUXuWawjtL8r92/q6 MoAkvCQfEYXeUufCmK6cbNWNxwLDr8qWgUGiRn/bgACGDs+FCmD+2OQ0LIttQ3fxOEPZ OID+wNDt28IidepvrNGuJrBMrqTGDS1hAokJNsMbMA9GA1RHHXeciczni3pjs41kv9Dk wx7ATtE74vPkIw94JjVgRR58yBVM/5qiDDH6cMg9OV+UVL1/5o5UPPbVd/JW8F9QEc9W a7c/vm8CP0h5+nzyN87njVfcCM5JnA5U1cVqZTD8V6L/DuFfZd8+nFBUJTippBf8S/BR ItnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7t0yCtklu7dcKbRDLlcm/F8iSnhf9vNHGW7kJ98+ijg=; b=FNvpoXCLicwzYnjY4jiYsms5t+VTtK+T69vfeDbecwGlAFHNH7obtArQEX5W/niXFX jrYKcPegmqVeHIgLZAXnslwFw1YpU2zg16uqWd2x+uzhVH5lZXAf4ZdJuB0+Ce9t0c8H yqO4W0xqkJDYmwa+w5lmehNieNz09BWmM3iGvSNvDktg8taodRIIG3jg6KytZP5xfUdW 6E5wr9Mla5xVyL6Kp0aSLNup5euqJbjzNppSBOQwH/J+VxoMG2U1OC8OpxZKXuzHa4ib GR0WhSpGsyafa1BXG8R3Afq7x0AtjK1wXx6gB6YRO5CFK/fhqk6MlOL/4AqwRneGYq9m r6TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JCLIgzHF; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a63af4f000000b005536fc5187asi2100593pgo.47.2023.06.20.10.25.19; Tue, 20 Jun 2023 10:25:35 -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=@infradead.org header.s=casper.20170209 header.b=JCLIgzHF; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230423AbjFTRF2 (ORCPT + 99 others); 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> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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, 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.