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=-0.8 required=3.0 tests=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 D2F1EC33C9E for ; Tue, 14 Jan 2020 19:19:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9D6A24656 for ; Tue, 14 Jan 2020 19:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728656AbgANTTJ (ORCPT ); Tue, 14 Jan 2020 14:19:09 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:44332 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgANTTJ (ORCPT ); Tue, 14 Jan 2020 14:19:09 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1irRiV-008EAO-3l; Tue, 14 Jan 2020 19:19:07 +0000 Date: Tue, 14 Jan 2020 19:19:07 +0000 From: Al Viro To: Amir Goldstein Cc: Jan Kara , linux-fsdevel Subject: Re: dcache: abstract take_name_snapshot() interface Message-ID: <20200114191907.GC8904@ZenIV.linux.org.uk> References: <20200114154034.30999-1-amir73il@gmail.com> <20200114162234.GZ8904@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Jan 14, 2020 at 08:06:56PM +0200, Amir Goldstein wrote: > > // NOTE: release_dentry_name_snapshot() will be needed for both copies. > > clone_name_snapshot(struct name_snapshot *to, const struct name_snapshot *from) > > { > > to->name = from->name; > > if (likely(to->name.name == from->inline_name)) { > > memcpy(to->inline_name, from->inline_name, > > to->name.len); > > to->name.name = to->inline_name; > > } else { > > struct external_name *p; > > p = container_of(to->name.name, struct external_name, name[0]); > > atomic_inc(&p->u.count); > > } > > } > > > > and be done with that. Avoids any extensions or tree-wide renamings, etc. > > I started with something like this but than in one of the early > revisions I needed > to pass some abstract reference around before cloning the name into the event, > but with my current patches I can get away with a simple: > > if (data_type == FANOTIFY_EVENT_NAME) > clone_name_snapshot(&event->name, data); > else if (dentry) > take_dentry_name_snapshot(&event->name, dentry); > > So that simple interface should be good enough for my needs. I really think it would be safer that way; do you want me to throw that into vfs.git (#work.dcache, perhaps)? I don't have anything going on in the vicinity, so it's not likely to cause conflicts either way and nothing I'd seen posted on fsdevel seems to be likely to step into it, IIRC, so... Up to you.