From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt0-f173.google.com ([209.85.216.173]:34443 "EHLO mail-qt0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752728AbdF2P4k (ORCPT ); Thu, 29 Jun 2017 11:56:40 -0400 Received: by mail-qt0-f173.google.com with SMTP id 32so78057485qtv.1 for ; Thu, 29 Jun 2017 08:56:39 -0700 (PDT) Message-ID: <1498751796.22569.9.camel@redhat.com> Subject: Re: [PATCH] Make statfs properly return read-only state after emergency remount From: Jeff Layton To: Carlos Maiolino , linux-fsdevel@vger.kernel.org Date: Thu, 29 Jun 2017 11:56:36 -0400 In-Reply-To: <20170629092540.7813-1-cmaiolino@redhat.com> References: <20170629092540.7813-1-cmaiolino@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, 2017-06-29 at 11:25 +0200, Carlos Maiolino wrote: > Emergency remount (sysrq-u) sets MS_RDONLY to the superblock but doesn't set > MNT_READONLY to the mount point. > > Once calculate_f_flags() only check for the mount point read only state, > when setting kstatfs flags, after an emergency remount, statfs does not > report the filesystem as read-only, even though it is. > > Enable flags_by_sb() to also check for superblock read only state, so the > kstatfs and consequently statfs can properly show the read-only state of > the filesystem. > > Signed-off-by: Carlos Maiolino > --- > fs/statfs.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/statfs.c b/fs/statfs.c > index 4e4623c..c1dfc37 100644 > --- a/fs/statfs.c > +++ b/fs/statfs.c > @@ -38,6 +38,8 @@ static int flags_by_sb(int s_flags) > flags |= ST_SYNCHRONOUS; > if (s_flags & MS_MANDLOCK) > flags |= ST_MANDLOCK; > + if (s_flags & MS_RDONLY) > + flags |= ST_RDONLY; > return flags; > } > IIUC, the superblock won't be writeable once MS_RDONLY is set, so every mount that uses it also becomes readonly regardless of how MNT_READONLY is set. LGTM: Reviewed-by: Jeff Layton