Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1301706rbb; Mon, 26 Feb 2024 05:26:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWb9kBK2x6OBpa1hOmyTp0xLHTYVvPSLMH95fG7N2+27CO6mz2a/T0aVhB0qr4uqK6OQqpuLRhuw1jV+kbVtMshTw50qyoqakNlNcHdOg== X-Google-Smtp-Source: AGHT+IF3zV35mpk0RcmtokvOLLGRxT3oNsahEZRhQuG3Yfsry/c0McndKSwGUeuQoojPffmUaGWp X-Received: by 2002:a17:90a:7565:b0:29a:6cf0:57a3 with SMTP id q92-20020a17090a756500b0029a6cf057a3mr4609959pjk.8.1708953994663; Mon, 26 Feb 2024 05:26:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708953994; cv=pass; d=google.com; s=arc-20160816; b=FLOpcIiO4oQWUU2j3M8+M+QB/EiemS4q0fuKczfR9YZwsWUsUJG+3bDnEn8/A8lzEp DdVUj0L8tW/0ftVC9pU+l2KBYVofVW7FQirfWZEdjw+us/1pF9xCL/Dt9jd2DYPVm1hi qzcb0Wrk8uS/5t3bu2kNM5kyjJ9ZqDH69Vb0FG5tqP2Zj8aUsrkutSu6El+qxQQWKu0P OENIRrjzU2vrE35krCjwRYEikpM9p7yMWQQ9LXgJ/ka8Uzk2o87FoI5LD9cR0xx4ftCn SGw9EDMRyNOO1Q2iC2KSaTIgC9I8k7FjssisjrCiDztCUsoQfkWEv1ZKqJbYV/7iYZOF O38g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=t4hzuDxrHS/Js4LiiCm4Q6xhHstJkeWoDThdJA8GDQw=; fh=NxEgvf8Rw6A11ITJWFIYtOfb5rphg3RFyVjPJ/rcJm4=; b=OttGIMbcw4Ti++nTuoxxYsYOGrsbG3Pl8TOGtzeLORVQe5xNpXYRBZaTTfo8IxQX+d 0RguyO7ErVszgkFA5i5AiWdz5NV6Zphx8/b+b2UAylx/H/1f/26njNygNu8un5z56Rq4 jutEERCvzCb7jaEigU1+TdQs+40Nz1xgMXixb2f00vEtYpH5sCK8m3zuzZ/aU3K7nB6l 05bgi2iMw0EAJR1YGql/Wrz+qce3L8RrdzWI+x0jBs7CYXBuEkcDo6CuPhGNo9vnL4el 1o6jPeE8GCaHSkf41UuwV7FuKwU7otMxaKPQinYQSuAqaNEuPSOGba/aQckpvMRo9c4X gLIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-81477-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81477-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id lk13-20020a17090b33cd00b0028cb18e31d5si3822256pjb.160.2024.02.26.05.26.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:26:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81477-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-81477-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81477-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 06741289267 for ; Mon, 26 Feb 2024 13:25:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87B9E12880A; Mon, 26 Feb 2024 13:25:45 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83C0D127B6E; Mon, 26 Feb 2024 13:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708953945; cv=none; b=og+EwdHTjy5DreTBNxvFAfNc8B80XYU/3VGRf4XLXfKeJ2sjsbzzyGBwFaVKoxO8p1xfdgc3MHVHpmvSq9YPwu6iAM6Js9Taw5U7VKeEilPxh+ymp5IhltKby8DA06vpMunUlZ18vvtdXZVmwmSHz7x/h444YFJc4TFeTgTtXHI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708953945; c=relaxed/simple; bh=u2OYFseBDBv+gj6x9L887oAOOsq7PZaQa4/b9bbukLo=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ib7NnJFlt+vTIgXtUttI02IDMd3A3bD+ptFyueuOyN1ZLzjMKInogxsMCfZQK1O9O8F6o8SR9cQKrOZevs5HYpCfK5LozC5/+vfoQ/BTUUc8fb16qxm2H9nH6DEa+GBLgaX1sogkGaAB9RhekDptir0Eb6UxY2Zk3ORTm0ihFBo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Tk1Ts4xsjz6K5xc; Mon, 26 Feb 2024 21:21:21 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 503B8140CB9; Mon, 26 Feb 2024 21:25:40 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 26 Feb 2024 13:25:39 +0000 Date: Mon, 26 Feb 2024 13:25:38 +0000 From: Jonathan Cameron To: John Groves CC: John Groves , Jonathan Corbet , "Dan Williams" , Vishal Verma , Dave Jiang , "Alexander Viro" , Christian Brauner , "Jan Kara" , Matthew Wilcox , , , , , , , Dave Chinner , Christoph Hellwig , , Subject: Re: [RFC PATCH 12/20] famfs: Add inode_operations and file_system_type Message-ID: <20240226132538.00002656@Huawei.com> In-Reply-To: References: Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500001.china.huawei.com (7.191.163.213) To lhrpeml500005.china.huawei.com (7.191.163.240) On Fri, 23 Feb 2024 11:41:56 -0600 John Groves wrote: > This commit introduces the famfs inode_operations. There is nothing really > unique to famfs here in the inode_operations.. > > This commit also introduces the famfs_file_system_type struct and the > famfs_kill_sb() function. > > Signed-off-by: John Groves Trivial comments only. > + > +/* > + * File creation. Allocate an inode, and we're done.. > + */ > +/* SMP-safe */ > +static int > +famfs_mknod( > + struct mnt_idmap *idmap, > + struct inode *dir, > + struct dentry *dentry, > + umode_t mode, > + dev_t dev) > +{ > + struct inode *inode = famfs_get_inode(dir->i_sb, dir, mode, dev); > + int error = -ENOSPC; > + > + if (inode) { As below. I would flip it for cleaner code/ shorter indent etc. > + struct timespec64 tv; > + > + d_instantiate(dentry, inode); > + dget(dentry); /* Extra count - pin the dentry in core */ > + error = 0; > + tv = inode_set_ctime_current(inode); > + inode_set_mtime_to_ts(inode, tv); > + inode_set_atime_to_ts(inode, tv); > + } > + return error; > +} > + > +static int famfs_mkdir( > + struct mnt_idmap *idmap, > + struct inode *dir, > + struct dentry *dentry, > + umode_t mode) > +{ > + int retval = famfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFDIR, 0); > + > + if (!retval) > + inc_nlink(dir); Copy local style, so fine if this is common pattern, otherwise I'd go for consistent error cases out of line as easier for us sleepy caffeine deprived reviewers. if (retval) return retval; inc_nlink(dir); return 0; > + > + return retval; > +} > + > +static int famfs_create( > + struct mnt_idmap *idmap, > + struct inode *dir, > + struct dentry *dentry, > + umode_t mode, > + bool excl) > +{ > + return famfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFREG, 0); > +} > + > +static int famfs_symlink( > + struct mnt_idmap *idmap, > + struct inode *dir, > + struct dentry *dentry, > + const char *symname) > +{ > + struct inode *inode; > + int error = -ENOSPC; > + > + inode = famfs_get_inode(dir->i_sb, dir, S_IFLNK | 0777, 0); if (!inode) return -ENOSPC; > + if (inode) { > + int l = strlen(symname)+1; > + > + error = page_symlink(inode, symname, l); if (error) { iput(inode); return error; } ... > + if (!error) { > + struct timespec64 tv; > + > + d_instantiate(dentry, inode); > + dget(dentry); > + tv = inode_set_ctime_current(inode); > + inode_set_mtime_to_ts(inode, tv); > + inode_set_atime_to_ts(inode, tv); > + } else > + iput(inode); > + } > + return error; > +}