Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp102651pxb; Thu, 14 Jan 2021 00:42:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVFZw7CyrCGUNe3XhgJpWa7l+LUsGyXpcleROxelpCp6xIbC+zag7VJZiu2lVvT7JhTYUU X-Received: by 2002:a05:6402:1a30:: with SMTP id be16mr5133870edb.124.1610613778128; Thu, 14 Jan 2021 00:42:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610613778; cv=none; d=google.com; s=arc-20160816; b=xegKCYOdAV9mtVe1qxpuBJb3pVRbTYJxkNlEiVjhx6QDl6OEdVFhjcuZodYrEW0RzF wx/rkR4JmaC27+sQ1xBFjJ+XulSen9muG7kx1oYSuOj9Pu3nxGa/tHWa4Ed+ZEv987nH +KQ9z6x5OtOZebeqjIYZ49br+Zh+zfSoreaHb8PU5m+V7lHcGrmyLar2rZM8RoCibGO7 S72xBCfXtRCG1dvd8xFSiSwQ7Ps6btFKeZXnU/Qq5PVXwAE+H/UwGn8AfUwRjxPnhLgt GTIxAd1BNrrqt3ZXQqtFBeQ08GybwXR31H4zOnRyjds+mqAEawtT2aoWbmFm+3ioYNxs Bh/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nCtrmkviUmQktLTVIGnwrV1sO0fnA2RJE1RYOo29das=; b=uGxjSri+OTgltUP0OEFy6fwMmNA85EACHYe5MMTaizmYQd6eihilf4G4YihEepRZ8t qTcVY9NgU+XRp6xe+QGZ0M3zVcl86x4giMT6NuAP/xzoiCKEbm7TZUPYgJBtEASTR0pg J/rTrylkdz5yyjwhW5N1wioBnmrLvH6BlvAx7br1JINy0Xm31OlV27ItH0kZxjZHn5uj 0T8pHuk4bY2QQPANQykmQhMwQuYL7hIZWJySl0iIfMD4O800ArSfg8Vkx6PbUU/8j0cc 3LHOadkR4XdBD/OMvnA/gBcjEL5x8zgup3usTw7OueD5qdA+EYYLDrzaTH/EXZDkbmjE 4XSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=lnOkDlN7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si2314845edt.581.2021.01.14.00.42.34; Thu, 14 Jan 2021 00:42:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=lnOkDlN7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727749AbhANIlf (ORCPT + 99 others); Thu, 14 Jan 2021 03:41:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726893AbhANIle (ORCPT ); Thu, 14 Jan 2021 03:41:34 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF7D0C061786 for ; Thu, 14 Jan 2021 00:40:47 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id dj23so2246813edb.13 for ; Thu, 14 Jan 2021 00:40:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=nCtrmkviUmQktLTVIGnwrV1sO0fnA2RJE1RYOo29das=; b=lnOkDlN7/8UGVYbFJTDV66RwQH6829K2lvepyTWbmrJT5RVZD+omMcYU7c+ztgtF+F GQvcaKrnxeTmT+uFqg7ZFP5F+jQyrI0JJrinGB97LRx+92T8BTpuRjptxdja/JTUk/NK P5mpSfUgYyGncrHLq21yo9pyA4ntXJjDz/zQ/T7mVHUtdyAfFaYFR6VBF8Ut/Eaos0Lr CgFl0md1kZY6NCNowoDCGxyUYkfU0GD91BBsoQvdF3OL0UKZh4nIbYmwcXWSuziVY+BO f2WCAgiSIulOwQNaD9KSXad8Zqau3MKhQhjcvJGHX2NCeyrpc6T0WwMWa1/I3FIg0DT+ b0bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=nCtrmkviUmQktLTVIGnwrV1sO0fnA2RJE1RYOo29das=; b=pDmxpBMEDv1vktmM/TW1JvGgGIi985PiIGrIj0P8r4z9bCSEDslI0vZrZjkTFUqiMy lQRVSltv82LZN37nJKNXb6OPluQtaH+bkuG4rjWMhhBU5Bu3Hqvf7A5RnYxb7ThA0P2W ybsT1rGQ+mTfhzJtNZilKoGrQ7+eiSkL/MixCuS+bYVQa7TrVksM3EUoqHXUGZuLZh6w SK+8eaqpxGmH2snJJndqxrpfoJew09NcCo82Dqy8ft5HPEdO3nw5iOmLn1UpLu4I8cu6 NGGHX1t7pH2XSV+lGD8ZP8lEUlnoR+1XRk+7snjaqMOF5z6aWTvLVoCWnTvo/cJAqtqz +S9g== X-Gm-Message-State: AOAM530MWoWZHYU1vGakfvESFh072efj50RV0lhR8wGlyadh2ApAMJlZ xnVhXJ9kxMVPOAW7G9g479NIEPKRpR3j5QzGNf02yBIgegA= X-Received: by 2002:a05:6402:17:: with SMTP id d23mr4993820edu.341.1610613646639; Thu, 14 Jan 2021 00:40:46 -0800 (PST) MIME-Version: 1.0 References: <20201125152247.30809-1-brgl@bgdev.pl> <20201125152247.30809-4-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Thu, 14 Jan 2021 09:40:36 +0100 Message-ID: Subject: Re: [PATCH 3/4] configfs: implement committable items To: Bartosz Golaszewski , Christoph Hellwig , LKML , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 14, 2021 at 12:46 AM Joel Becker wrote: > > On Wed, Nov 25, 2020 at 04:22:46PM +0100, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > This implements configfs committable items. We mostly follow the > > documentation except that we extend config_group_ops with uncommit_item() > > callback for reverting the changes made by commit_item(). > > Woohoo! A long time coming, but thank you for working on the > implementation! > > > Each committable group has two sub-directories: pending and live. New > > items can only be created in pending/. Attributes can only be modified > > while the item is in pending/. Once it's ready to be committed, it must > > be moved over to live/ using the rename() system call. This is when the > > commit_item() function will be called. > > The original API intended for live items to still be modifyable. The > live/ path forbids mkdir()/rmdir(), but it allows store(). Otherwise, > items can't be adjusted at all while in use, which is severely limiting. > Obviously the store() handler must not allow transitions from > valid-value->invalid-value, but the handler would reject invalid values > anyway, wouldn't it? > > > diff --git a/fs/configfs/file.c b/fs/configfs/file.c > > index 1f0270229d7b..a20e55fd05e8 100644 > > --- a/fs/configfs/file.c > > +++ b/fs/configfs/file.c > > @@ -243,9 +243,17 @@ fill_write_buffer(struct configfs_buffer * buffer, const char __user * buf, size > > static int > > flush_write_buffer(struct file *file, struct configfs_buffer *buffer, size_t count) > > { > > + struct config_item *parent_item = buffer->item->ci_parent; > > struct configfs_fragment *frag = to_frag(file); > > + struct configfs_dirent *sd; > > int res = -ENOENT; > > > > + if (parent_item && parent_item->ci_dentry) { > > + sd = parent_item->ci_dentry->d_fsdata; > > + if (sd->s_type & CONFIGFS_GROUP_LIVE) > > + return -EPERM; > > + } > > + > > down_read(&frag->frag_sem); > > if (!frag->frag_dead) > > res = buffer->attr->store(buffer->item, buffer->page, count); > > Basically, I would just leave this hunk out. > I would make this configurable per-attribute because for the use-case I need this for we definitely don't want the items to be modifiable once they're "live". Bartosz