Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp298832pxb; Thu, 14 Jan 2021 06:21:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoK5u29iCFRhwg6F3s2cvr1H9A1Ef4yd8W6WsGb7HjR6+Z5y9l92gOqTuUZZPgPxLP5/G4 X-Received: by 2002:a05:6402:202e:: with SMTP id ay14mr6166820edb.102.1610634084577; Thu, 14 Jan 2021 06:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610634084; cv=none; d=google.com; s=arc-20160816; b=WFrQgJdeC9xgFc9UFKVAWD+D5EfvqS/WtTOHksBCURWrgSY8MbUkeRsW3drV5qloPY IRzGg4gUWzZLB7xmKO9c8rwKd+QwyGfm9f2qjAakvuO+k/39T/A71MEmtxjb2WG1SbXw 0YkIx6Ca3LDAeUYltDMTaIDSUnEF8QPwMaecw1FN1Bz630LfQ4V4bcAqLP1XfWuJQth2 OCvRnSD+uZ2ALP3I122kXn/nO9lGRXFMA4FsnglAhkw2NbvQM5Mi4oo7/KVKoZNK+h9x jOb78PIo2ij2hgVxes0GPzxc9J32dDDIImH53vvRHbgMws1O7Zk5wCDsZig9dZAO6Hmg P2oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ehumhbovMQDBmbv6S/fWaQDWOkoIxN7QeqVysJIGvCE=; b=gTB9btSnrI6eGs/sUlbUhB9rMnGm/okmxhP0DZV0ZeuW3DSfGCqwCRCqaOh6OGxtji 39TOSO2zyeyrzgiUEGux6RodVvxCWUZJWyFxt+V3GdSmg/g1F/OjJSgZzWF5JWceZgzO ZCpEzWM8ZIFtDuOeF2K23n/sBN+FYGdEgQzXx1B6A2OW8ZyH7uGLAppFoMsnZp3m+hg8 vOuppFJMi4jIKk+prE5rE/pXvvPGI4rH9EQAzdgqEX48ia9B1K+tWGV1LzYAV/g3dzCQ kiMNqNTr9R8h5msGpO+zSOTxaUF+0s5y+izjnOUbZE1dlLCu/D3S+QY+e69jEYRT+0LN /KcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=TtoLQsTQ; 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 hr15si2383490ejc.287.2021.01.14.06.20.59; Thu, 14 Jan 2021 06:21:24 -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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=TtoLQsTQ; 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 S1727562AbhANOUL (ORCPT + 99 others); Thu, 14 Jan 2021 09:20:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbhANOUK (ORCPT ); Thu, 14 Jan 2021 09:20:10 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2D4BC061574 for ; Thu, 14 Jan 2021 06:19:29 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id q22so8405143eja.2 for ; Thu, 14 Jan 2021 06:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ehumhbovMQDBmbv6S/fWaQDWOkoIxN7QeqVysJIGvCE=; b=TtoLQsTQ8Tw17+inL6jLVEIF0Mwr3eUOZzPszfr9oJvXUSZ/rFJW5stu1uhaVSr1hv hskDQgtzgrh/SxEOn3ocJnfAzQKll+UtGUKqMfzgOCtRqA3X0gRvQsqMJUJOCtrQuHLo 8ZD3uIH2mAE2GHGM8f3VsxWCQiYR2DfnQbHwThXycm4yMEPcKcbjGb2sGKA1Mt/2V6eI j2WE+n69ZHwZ6dGL3PkDkh4TvzhQWyWHxlEvs+FqI5lw08Zh12Kk23rNrDPouEAJiFzV xbrOvnX50H9myHDXAxJCWAeG2Hqz0GHCNI4lcmAM+47dToNoz+EYh5RE6XIY6b9Jot9g kONg== 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:cc; bh=ehumhbovMQDBmbv6S/fWaQDWOkoIxN7QeqVysJIGvCE=; b=S8x/KgzDW0xBhgmYbweJFzg/AIkQkM9MEQNnmZyymJp7IfmXw43DgB0+vRUoqYoS7l wsVzG4qwMa8OJr4MWu2DoKvrmauz5btFHdREJHrPpq08BQmEWOIrUnII6D9mUxJuIbDb VUGz8cN4rWLK1xTWEANJqZhY8yoNdRTwFSpWMvTTHF76orD9P3oYtwh6xfWW2t/5Hm73 OxQ2IyJPMo2oHhSZHsBzDgVSauYafZ9hpR6QXon5qCE8FC8nDm/tv3myUq023X5Mb4NJ Bxf4wlaRJhxiFCZBEtj/feNDiWNBzz49wLTyyjWUBSrqN/g4B68Be9xjB6+lD0yuvK2C mFUg== X-Gm-Message-State: AOAM530wHjHUWNiIRfB26PcS89UqeT/ql+xQkn7ab8FsvYqbuMNCrE1R ASp9eD5KH5PwjhcJV5kSqUpZKYz7/0+W4fvzXnloUD2zYAM= X-Received: by 2002:a17:906:5912:: with SMTP id h18mr5354396ejq.261.1610633968405; Thu, 14 Jan 2021 06:19:28 -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 15:19:17 +0100 Message-ID: Subject: Re: [PATCH 3/4] configfs: implement committable items To: Bartosz Golaszewski Cc: Christoph Hellwig , LKML 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 9:40 AM Bartosz Golaszewski wrote: > > 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 After a second thought: I agree this can be left to the user's discretion so I'll just remove this and enforce it in the sample code. One thing I'm unsure about is whether we should allow to change the group's name when moving it from pending to live. Any thoughts? Bartosz