Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753254AbcDOCTy (ORCPT ); Thu, 14 Apr 2016 22:19:54 -0400 Received: from ipmail05.adl6.internode.on.net ([150.101.137.143]:9492 "EHLO ipmail05.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753142AbcDOCTw (ORCPT ); Thu, 14 Apr 2016 22:19:52 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DVDwAyTxBXNaAZLHlegziBUIZrnzEBAQEBAQEGjBGFaIQOhggEAgKBO00BAQEBAQEHAQEBAUEBQIRCAQEEJxMcIxAIAxgJJQ8FJQMHGhOIKMJJAQEIAh4ZhUCFE4oVBZgLjgSPG48phFsqMIlGAQEB Date: Fri, 15 Apr 2016 12:17:37 +1000 From: Dave Chinner To: Florian Margaine Cc: Alexander Viro , Jeff Layton , "J. Bruce Fields" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs: add the FIGETFROZEN ioctl call Message-ID: <20160415021737.GZ567@dastard> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1164 Lines: 35 On Thu, Apr 14, 2016 at 09:57:07AM +0200, Florian Margaine wrote: > This lets userland get the filesystem freezing status, aka whether the > filesystem is frozen or not. This is so that an application can know if > it should freeze the filesystem or if it isn't necessary when taking a > snapshot. freezing nests, so there is no reason for avoiding a freeze when doing a snapshot. Indeed, if you don't wrap freeze/thaw around a snapshot, then if the fs is thawed while the snapshot is in progress then you are going to get a corrupt snapshot.... And, besides, polling for frozenness from userspace is inherently racy - by the time the syscall returns, the information may be incorrect, so you can't rely on it for decision making purposes in userspace. > +static int ioctl_fsgetfrozen(struct file *filp) > +{ > + struct super_block *sb = file_inode(filp)->i_sb; > + > + if (!capable(CAP_SYS_ADMIN)) > + return -EPERM; > + > + return sb->s_writers.frozen; This makes the internal freeze implementation states part of the userspace ABI. This needs an API that is separate from the internal implementation... Cheers, Dave. -- Dave Chinner david@fromorbit.com