Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5450170imm; Tue, 18 Sep 2018 09:41:36 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda55jaJZYvF9fFOocY6stPmt9gEoptiibE9kN9mPLYgyVAFAqYLHKgZPrALWQCeUJFPkwvF X-Received: by 2002:a63:1e0b:: with SMTP id e11-v6mr28256049pge.44.1537288896285; Tue, 18 Sep 2018 09:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537288896; cv=none; d=google.com; s=arc-20160816; b=YsBJXIMg7V4NBGjy/G9ugSdwD9580vmq7zx1ug7AX5Dj+xBpHCHgEbklHOpGLWUxB5 hf+GNf/+ZdQ7OqJsSqtQMO1HSEjjCN3R8FJX3Gr/i57OomEX//I2+VqSNC40SxjLQ3Cm OV4n4IShxuXwwvKO1dDcgn85pCPMIYrFAJyU+eBQrQ1S7ZpiVoj6QEfLw+Z0KHvqOCKm P6FMWin5eG7uC0v/xcGe/HBFFrF4ao9L05hFRz/lPP1mpUEFYjuWblsacCBv8tBc8dTd VTDgUr12nWVlaA1xNym3Q4ZtM4ABbzw4DuCC7MxdMcFghsFhqlDllsmhsXAoomR/1+p4 6ADw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization; bh=GsMzwH65ZuWzvWAGvraQKUKf05PEYo7OIyqr+bqnCs0=; b=bpAXO3Diaz/q+1J9fiKnRwUgytpUjGVYoKuCZjHU39hZVTV9lcc+oxYp1iU/omgOJe venKu3bRfJI4zfXVJbJITLrKj5YbvFpBayJj5bfhruc6ZMb8puRGjCGjv6nfLFi/ziXz cY2i7IXhPXaJ1a02GBCpExDrxNBCtWzXIkC0rY/Fs/hnO14P2ZOwxFccWjhCUVV6ogdw Z46aJhDEGshceXiZUr1hwVdAC/y1bjBo9H39c1cYJQ5Qp1Npoa+xBTfrTKoqfUUM4iKu NSx6vhLFp+zc6RzXbNoQY/UcoDqpmnycg9e6xlPpmdG/d3mvdW3shQYSfSyaGZUeu5v6 hsvQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14-v6si18442437pgo.449.2018.09.18.09.41.21; Tue, 18 Sep 2018 09:41:36 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730232AbeIRWM2 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Sep 2018 18:12:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36386 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729998AbeIRWM2 (ORCPT ); Tue, 18 Sep 2018 18:12:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 593B58666B; Tue, 18 Sep 2018 16:39:05 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-123-84.rdu2.redhat.com [10.10.123.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79E417DEE4; Tue, 18 Sep 2018 16:39:03 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20180918090722.GA463@jagdpanzerIV> References: <20180918090722.GA463@jagdpanzerIV> <20180911220743.GA13208@roeck-us.net> <20180911174641.GA15149@roeck-us.net> <153313703562.13253.5766498657900728120.stgit@warthog.procyon.org.uk> <153313714181.13253.304098108512966976.stgit@warthog.procyon.org.uk> <27113.1536702746@warthog.procyon.org.uk> <32382.1536707855@warthog.procyon.org.uk> <20180911235403.GA10107@roeck-us.net> To: Sergey Senozhatsky Cc: dhowells@redhat.com, Guenter Roeck , viro@zeniv.linux.org.uk, torvalds@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Steven Rostedt Subject: Re: [PATCH 14/33] vfs: Implement a filesystem superblock creation/configuration context [ver #11] MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27018.1537288742.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Tue, 18 Sep 2018 17:39:02 +0100 Message-ID: <27019.1537288742@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 18 Sep 2018 16:39:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I think I need to include something like the attached change in this patch. Changes also need to be made to proc and cgroup. David --- commit 1a336480a0f664b3e1988a581bccd4fa10d98764 Author: David Howells Date: Tue Sep 18 17:25:23 2018 +0100 fix remount diff --git a/fs/fs_context.c b/fs/fs_context.c index a82679441031..1f36b72e3ee9 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -42,8 +42,6 @@ struct legacy_fs_context { enum legacy_fs_param param_type; }; -static int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry); - static const struct constant_table common_set_sb_flag[] = { { "dirsync", SB_DIRSYNC }, { "lazytime", SB_LAZYTIME }, @@ -293,7 +291,6 @@ struct fs_context *vfs_new_fs_context(struct file_system_type *fs_type, break; } - /* TODO: Make all filesystems support this unconditionally */ init_fs_context = fc->fs_type->init_fs_context; if (!init_fs_context) @@ -662,12 +659,20 @@ const struct fs_context_operations legacy_fs_context_ops = { * Initialise a legacy context for a filesystem that doesn't support * fs_context. */ -static int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry) +int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry) { + switch (fc->purpose) { + default: + fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), + GFP_KERNEL); + if (!fc->fs_private) + return -ENOMEM; + break; - fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL); - if (!fc->fs_private) - return -ENOMEM; + case FS_CONTEXT_FOR_UMOUNT: + case FS_CONTEXT_FOR_EMERGENCY_RO: + break; + } fc->ops = &legacy_fs_context_ops; return 0; diff --git a/fs/internal.h b/fs/internal.h index d25cb82af69d..fc2da60abbcd 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -55,6 +55,7 @@ extern void __init chrdev_init(void); * fs_context.c */ extern const struct fs_context_operations legacy_fs_context_ops; +extern int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry); /* * fsopen.c diff --git a/fs/namespace.c b/fs/namespace.c index ddb2c3b88cd6..86b60566fcdf 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1429,9 +1429,19 @@ static int do_umount_root(struct super_block *sb) }; down_write(&sb->s_umount); - if (!sb_rdonly(sb)) - /* Might want to call ->init_fs_context(). */ - ret = reconfigure_super(&fc); + if (!sb_rdonly(sb)) { + int ret; + + if (fc.fs_type->init_fs_context) + ret = fc.fs_type->init_fs_context(&fc, NULL); + else + ret = legacy_init_fs_context(&fc, NULL); + + if (ret == 0) { + ret = reconfigure_super(&fc); + fc.ops->free(&fc); + } + } up_write(&sb->s_umount); return ret; } @@ -2396,7 +2406,7 @@ static int do_remount(struct path *path, int ms_flags, int sb_flags, err = security_fs_context_validate(fc); if (err) - return err; + goto err_fc; down_write(&sb->s_umount); err = -EPERM; diff --git a/fs/super.c b/fs/super.c index e00b03249bfa..df8c4cebd000 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1026,12 +1026,20 @@ static void do_emergency_remount_callback(struct super_block *sb) down_write(&sb->s_umount); if (sb->s_root && sb->s_bdev && (sb->s_flags & SB_BORN) && - !sb_rdonly(sb)) - /* Might want to call ->init_fs_context(). */ + !sb_rdonly(sb)) { + int ret; + + if (fc.fs_type->init_fs_context) + ret = fc.fs_type->init_fs_context(&fc, NULL); + else + ret = legacy_init_fs_context(&fc, NULL); + /* * What lock protects sb->s_flags?? */ - reconfigure_super(&fc); + if (ret == 0) + reconfigure_super(&fc); + } up_write(&sb->s_umount); }