Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1771966imm; Thu, 14 Jun 2018 03:43:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKITYAPhADvfQ0rRXtjt76eTN7yAGh0/eHgCqJMU6JTFo8Cvsh7gl+EYzr1Xy2CJ2ZSeSehe X-Received: by 2002:a62:ae06:: with SMTP id q6-v6mr8875492pff.17.1528973004332; Thu, 14 Jun 2018 03:43:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528973004; cv=none; d=google.com; s=arc-20160816; b=FGxw76Ez7AMsTSK7B5EylZpaHKSWY07hF2/c0nEElYPuuWNWaz2iJe4ZYMHzCBaoAy WsMVxtALfS2xJTA3ut6pUoRq2LALAn9k2voqlQWQEFyXjPbg6QSaTj4G9ad1CbDmILkk Ceel64RL9hZGD1O14XWj1pYK+CPVhQzLGd8Vlx9ZtW6qwZO8tz3gOePI6ZbXQ1OoRnMn K/Y/K2e4lj3gjyUiKW+p0khRDILmIMMc+C/vn6boJnUMEL4yH5QqEiYLVqynwzDJ9FFm 10Ev10BqEzd+Kqf8u6QBqJBWHx+bs8jaPjXT3dxH8uIRpjp7xO3R8WrFhu2hA2/KJqyF A2Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=MiyzBKFLA9SGNNlQktq/TzETacDBXLY8JSZM7QAnKC8=; b=alqHfSIZcVL9yAw2Ny1pso3NSXQgY6XqVCP++55bhf99xlZ8Lj04frVQ2hIqB7faC/ xidZqjzGpIwjAZ7f59Y0pTc7LtvcX5fMeVKp0IEsy/eb6/pdnQMU91/8Q5RM5VKfC4Pq 3GkglLlVUrpdkdkbSnOaF5+bd35kwGX/R+eShaGfIgu0etYM9it03nBohWjBEUk3PHmh QQVf09LZcGDj8h/hkzJ5Mgf+TqFqe1LktBNNj7hV4xEPSWmTDS31nF0/tMKHL2ImP9Dw 4wixBpDZF1dzsnWqr6mvFkY5kA4a7HpJLsv+fsYCoOcCAj31S6A15+K+nOGJuRi7ubH6 Ygmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Z7kH68u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si5259924plg.260.2018.06.14.03.43.09; Thu, 14 Jun 2018 03:43:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Z7kH68u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1754983AbeFNKlX (ORCPT + 99 others); Thu, 14 Jun 2018 06:41:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:37870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754857AbeFNKlV (ORCPT ); Thu, 14 Jun 2018 06:41:21 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 29BDA208CB; Thu, 14 Jun 2018 10:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528972881; bh=GSLLYrtGeb9CojeSy2RWtQ5ZoBNxTgwm6fujxy4HvNk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=0Z7kH68uFNcYFy9d8T7MzyvQfbGYv4iCuYexiXq7gDd88jkajt9poDW9l3wxzOrtv uk2bFR0nDZKM5Bl8h8xgtAsPmI7/KX+gYVFWyrCXYq/LIA/t1nkhGmwcAAotDP9hcl Z6oJUQQ6olRsukPH7rFxUXbACNhJsjsMymJ8MrV4= Message-ID: <8f1ff99c80db2df5947bd7880028818e2e878fdd.camel@kernel.org> Subject: Re: [PATCH 0/2] fs/lock: show locks info owned by dead/invisible processes From: Jeff Layton To: Konstantin Khorenko , Kirill Gorkunov , Andrey Vagin , Benjamin Coddington , "J. Bruce Fields" , Alexander Viro Cc: Vasily Averin , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 14 Jun 2018 06:41:18 -0400 In-Reply-To: <20180608142712.32460-1-khorenko@virtuozzo.com> References: <20180608142712.32460-1-khorenko@virtuozzo.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.2 (3.28.2-1.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2018-06-08 at 17:27 +0300, Konstantin Khorenko wrote: > The behavior has been changed after 9d5b86ac13c5 ("fs/locks: Remove fl_nspid > and use fs-specific l_pid for remote locks") > and now /proc/$PID/fdinfo/$FD does not show the info about the lock > * if the flock owner process is dead and its pid has been already freed > or > * if the lock owner is not visible in current pidns. > > CRIU uses this interface to store locks info during dump and thus can break > on v4.13 and newer. > > So let's show info about locks anyway in described cases (like it was before > 9d5b86ac13c5), but show pid number saved in file_lock struct if we are in > init_pid_ns (patch 1) or just zero otherwise (patch 2) like we do with SID. > > Reproducer: > process A process A1 process A2 > fork()---------> > exit() open() > flock() > fork()---------> > exit() sleep() > > Before the patch: > ================ > (root@vz7)/: cat /proc/${PID_A2}/fdinfo/3 > pos: 4 > flags: 02100002 > mnt_id: 257 > lock: (root@vz7)/: > > After the patch: > =============== > (root@vz7)/:cat /proc/${PID_A2}/fdinfo/3 > pos: 4 > flags: 02100002 > mnt_id: 295 > lock: 1: FLOCK ADVISORY WRITE ${PID_A1} b6:f8a61:529946 0 EOF > > =============== > # cat flock1.c > > #include > #include > #include > #include > #include > #include > #include > > int main(void) > { > int fd; > int err; > pid_t child_pid; > > child_pid = fork(); > if (child_pid == -1) > perror("fork failed"); > if (child_pid) { > exit(0); > } > > fd = open("/tmp/a", O_CREAT | O_RDWR); > if (fd == -1) > perror("Failed to open the file"); > > err = flock(fd, LOCK_EX); > if (err == -1) > perror("flock failed"); > > child_pid = fork(); > if (child_pid == -1) > perror("fork failed"); > if (child_pid) > exit(0); > > sleep(10000); > > return 0; > } > > Konstantin Khorenko (2): > fs/lock: skip lock owner pid translation in case we are in init_pid_ns > fs/lock: show locks taken by processes from another pidns > > fs/locks.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > These look fine to me. I'll plan to pick them up for v4.19 unless anyone has objections. Thanks! -- Jeff Layton