From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f67.google.com ([209.85.218.67]:41065 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733129AbeGLXgK (ORCPT ); Thu, 12 Jul 2018 19:36:10 -0400 Received: by mail-oi0-f67.google.com with SMTP id k12-v6so58940004oiw.8 for ; Thu, 12 Jul 2018 16:24:22 -0700 (PDT) MIME-Version: 1.0 References: <153126248868.14533.9751473662727327569.stgit@warthog.procyon.org.uk> <153126264966.14533.3388004240803696769.stgit@warthog.procyon.org.uk> <686E805C-81F3-43D0-A096-50C644C57EE3@amacapital.net> <22370.1531293761@warthog.procyon.org.uk> <7002.1531407244@warthog.procyon.org.uk> <16699.1531426991@warthog.procyon.org.uk> <18233.1531430797@warthog.procyon.org.uk> <20180712223223.GA28610@thunk.org> <22105.1531436081@warthog.procyon.org.uk> In-Reply-To: <22105.1531436081@warthog.procyon.org.uk> From: Jann Horn Date: Thu, 12 Jul 2018 16:23:54 -0700 Message-ID: Subject: Re: [PATCH 24/32] vfs: syscall: Add fsopen() to prepare for superblock creation [ver #9] To: David Howells Cc: "Theodore Y. Ts'o" , Linus Torvalds , Andy Lutomirski , Al Viro , Linux API , linux-fsdevel@vger.kernel.org, kernel list Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Jul 12, 2018 at 3:54 PM David Howells wrote: > > Theodore Y. Ts'o wrote: > > > So maybe the answer is that you open /dev/sda1 and /dev/sda2 and then > > pass the file descriptors to the fsopen object? We can require that > > the fd's be opened with O_RDWR and O_EXCL, which has the benefit where > > if you have multiple block devices, you know *which* block device had > > a problem with being grabbed for an exclusive open. > > Would that mean then that doing: > > mount /dev/sda3 /a > mount /dev/sda3 /b > > would then fail on the second command because /dev/sda3 is already open > exclusively? Not exactly. mount_bdev() uses FMODE_EXCL, which locks out parallel usage *with a different filesystem type*. This is the effect: # strace -e trace=mount mount -t vfat /dev/loop0 mount mount("/dev/loop0", "/home/jannh/tmp/x/mount", "vfat", MS_MGC_VAL, NULL) = 0 +++ exited with 0 +++ # strace -e trace=mount mount -t ext4 /dev/loop0 mount mount("/dev/loop0", "/home/jannh/tmp/x/mount", "ext4", MS_MGC_VAL, NULL) = -1 EBUSY (Device or resource busy) mount: /home/jannh/tmp/x/mount: /dev/loop0 already mounted on /home/jannh/tmp/x/mount. +++ exited with 32 +++ I don't really understand why it's not more strict though...