From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72F25C2D0A8 for ; Wed, 23 Sep 2020 17:03:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 371AD20C09 for ; Wed, 23 Sep 2020 17:03:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbgIWRDa (ORCPT ); Wed, 23 Sep 2020 13:03:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726381AbgIWRD3 (ORCPT ); Wed, 23 Sep 2020 13:03:29 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A97BEC0613CE; Wed, 23 Sep 2020 10:03:29 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kL8As-004fka-To; Wed, 23 Sep 2020 17:03:23 +0000 Date: Wed, 23 Sep 2020 18:03:22 +0100 From: Al Viro To: Alexander Mikhalitsyn Cc: avagin@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] fsopen: fsconfig syscall restart fix Message-ID: <20200923170322.GP3421308@ZenIV.linux.org.uk> References: <20200923164637.13032-1-alexander.mikhalitsyn@virtuozzo.com> <20200923164637.13032-2-alexander.mikhalitsyn@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200923164637.13032-2-alexander.mikhalitsyn@virtuozzo.com> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 23, 2020 at 07:46:36PM +0300, Alexander Mikhalitsyn wrote: > During execution of vfs_fsconfig_locked function we can get ERESTARTNOINTR > error (or other interrupt error). But we changing fs context fc->phase > field to transient states and our entry fc->phase checks in switch cases > (see FS_CONTEXT_CREATE_PARAMS, FS_CONTEXT_RECONF_PARAMS) will always fail > after syscall restart which will lead to returning -EBUSY to the userspace. > > The idea of the fix is to save entry-time fs_context phase field value and > recover fc->phase value to the original one before exiting with > "interrupt error" (ERESTARTNOINTR or similar). If you have e.g. vfs_create_tree() fail in the middle of ->get_tree(), the only thing you can do to that thing is to discard it. The state is *NOT* required to be recoverable after a failure exit - quite a bit of config might've been consumed and freed by that point. CREATE and RECONFIGURE are simply not restartable.