Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp5924rbb; Fri, 23 Feb 2024 09:56:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUaYM37kIow6iJKA53nFeLaqkKxshqdxWy89GwdeXEz8FvjbjZ2rUUaz4aYtSRaNX8DGdM501uUeOJOSeejENwo7UmKTnaERpPiXSOw4Q== X-Google-Smtp-Source: AGHT+IHr9EcWUPN6dBrtqxhgybXEeaAZl49AgGo+nwEd39T0nKRpCBgffA/4/Ph3SCJtNcEo975y X-Received: by 2002:a17:90a:4207:b0:299:1aa6:f20b with SMTP id o7-20020a17090a420700b002991aa6f20bmr547153pjg.21.1708710972729; Fri, 23 Feb 2024 09:56:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708710972; cv=pass; d=google.com; s=arc-20160816; b=tqplSv4ek/WCaIqWpzeo15b+KgRKHS7P6HOwzB+gB0cKYRHSu1MVort77th1djkjyt ZgHy+pOSQHX3ZvjV7qm3gpyi+sO6U2zDYzdeb0ubjqi9b3PkPKkAAorYDvh4qqlc3HBg jpCuG8QyXqTQ7RZGNv7TZhYq8dkhuSqKc4IPFjpxTmmVdZDWfeWf+fwGROlDCF28rXW1 U0FX/5sSJPK7neBYGCVYUBN+JN9v4tNnFyK3pbkk1iE42YfpbOnFdcF3WtFYVbLpmgJD awNI5Je7NNqZAntqefzl7WFL9JwfcBpivkrebMvvrk68UNk3SGkxhmqfmGLnb3b0E67s UT6Q== 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:references:in-reply-to:message-id :date:subject:cc:to:from:sender:dkim-signature; bh=p6QjmLkc27iMh7yi/z9o9l9CtGVPifxNLsali304Bg4=; fh=kPi2AW4+Kzr3sEKAd7P95Ja7oIOcW0MtMT2Z0Z/ynPc=; b=QCTrXy04KTnNZGywHqpN/svQTRJwYwOdgzxKvyuZjhBuxouIvB1yHFVLvcXddrVWxg FsXUZZwaXmc0ynr2wAlGUJpCu0dhcQAtbcvIRVCBYaT8hLFD/7lBvxptMeBFUoagFhcF 4mwbjTUOpEB20cu8IEvOorzjl8Ch99Hh25NOrMLoQJkubrtleXufaWS/VfChC2U6/xPd zfPKGuXc4dx7RyMAmE7cCOl/LqqnsBkpL0h4ZxwJH4wNaaOFJqspAKbobY9/7Y4yXEr0 MhgWiBDc2h8i2iGyW4ciOl6FEpJ5yn8eR22SHuRRJb1U8wtKNCHqmtAQdUVsu7mZE5yS ctpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RgtNX9H+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-78899-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78899-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id iz6-20020a170902ef8600b001dc07b8d0a9si8345114plb.109.2024.02.23.09.56.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 09:56:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78899-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RgtNX9H+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-78899-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78899-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E62A1B258BD for ; Fri, 23 Feb 2024 17:46:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 823EE1448DB; Fri, 23 Feb 2024 17:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RgtNX9H+" Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9452143C6A; Fri, 23 Feb 2024 17:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710174; cv=none; b=ju1/kkSi/VB/IkGJwloo24rF9Q/Gp2dz0+kkgb15t+eXsJQWgd5jHIv2+dzky6nUTQwBy9EytRt/UJ8yL7cdUp9NFsRPeARxCsZiMktxYVZn+DOAwsbN292fN9/Jy2lhSXQ2bUkzGZ3YxEGUJgNzOHWS+5v1SEkDM+rlV4lTjnA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708710174; c=relaxed/simple; bh=VCUvYUMBePLjAnqLXIh0xC3E0ySm6TUv3Sa00+ZpFwE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZZ7x0dKWCC/hWhNDHW8lWITYfPJ/zsx0AlcQ0ZCkQRcaI/v8VC1G0hZLfzLN4xZ3Z7LxEZd1oG/N9/AZfAxUBKJ5evAoPgEiaMq3ad7XiDd+5zpVyXjlLxr8ZmNX2XYo7uuTSWHqkcQfYBKcthyFoEEhwf9YN80qsh92c25gAPA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RgtNX9H+; arc=none smtp.client-ip=209.85.160.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-21f70f72fb5so627842fac.1; Fri, 23 Feb 2024 09:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708710172; x=1709314972; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=p6QjmLkc27iMh7yi/z9o9l9CtGVPifxNLsali304Bg4=; b=RgtNX9H+kqUWjxLDyFr2RFG9MQRbtobQujYZvqCo1BjLgI9OLOcgkUzyhLlcRCLJoj M0fS9+4xJdC0A9THjSXQnxuJIO1QYaPMAnrXV4AqgCA6p3cOBNl8c9JERglzWOstd8O+ 22y/9lbsgetJiXmdBp6PJFNHH6bpfBbQr6R//BpvEFDf2kcQKMLJ7ZXoNDcURWW+t+0U 0SZwoOIp3d+eYjIswQ1jKHLHj70CTyHVhyxH56qoABwMSv31LqXhvrr8KLKElTYENSsf es4r3jTZsSGcdN4fJOpoyRT1aDYALD1c2LoKDbN2DmUIZchryxJFZ6vFfhqFhVztHUuC sI3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708710172; x=1709314972; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=p6QjmLkc27iMh7yi/z9o9l9CtGVPifxNLsali304Bg4=; b=F3tQT/Tz1jktYzfDGtXTaqeCrl4gCCAbuE8zpwSz3j0CPIoY4f4kzOiAdsVsnj5kMu +EyiOiFc8ECVmnM4h4WiDFxLwb1f5FocFeOEQm66K4t1WFuw8Wm0KHDh589Ze0+fIJkE srnYamTfTq4L9PkIqP2Nnzf/OHlGnpl8ayhkXwWXArbluWdFhADRcxaqdJO+bzU5qdfh 90G8rgptjshUAR9chvLrWuoGuUy4HqBPnLBh8K65lr8arxBdV/u4H/CYJeYSnZ1jzrN1 zJiqjgGcb/P+7bnTTNOrLSgj2lkjrp8i+9v0YMQItDRg57rrKfc8jJY0ZEOBW9lCNn1d sIGQ== X-Forwarded-Encrypted: i=1; AJvYcCXFpEp8yQn2e8FgUbPKR0Em8leuiKlDlYcLPbNsiM1Ym5qR2XLDqh/jxKgmF5SQbQDJTeQQUfXcfNKxjt8FvMwR1p24cqImG8TVrlnXWP1Q3iUApj8ujor6pBXYd4L5wp/fjlxhH5Rk0373Fi06IM3SuqQylhob9mpczo0QZiPiPzhtRSkm49qdyfhvRp/DlIVz9NH/+fbCpxHImAM+9Ihvfg== X-Gm-Message-State: AOJu0Yx41x8JwHQI/OYOThoLmcyTL+ZKBgQM6HJQhi9RaTKRd8KM3Btb Q8esfJOxv0xxmVpgOK0UjekF6w9D6eQUmzxzb320q9b1xSywgx8I X-Received: by 2002:a05:6871:4585:b0:21f:6758:d5b0 with SMTP id nl5-20020a056871458500b0021f6758d5b0mr489470oab.50.1708710171814; Fri, 23 Feb 2024 09:42:51 -0800 (PST) Received: from localhost.localdomain (070-114-203-196.res.spectrum.com. [70.114.203.196]) by smtp.gmail.com with ESMTPSA id rb7-20020a056871618700b0021f6a2bd4b9sm1257803oab.3.2024.02.23.09.42.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 09:42:51 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: John Groves , Jonathan Corbet , Dan Williams , Vishal Verma , Dave Jiang , Alexander Viro , Christian Brauner , Jan Kara , Matthew Wilcox , linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Cc: John@Groves.net, john@jagalactic.com, Dave Chinner , Christoph Hellwig , dave.hansen@linux.intel.com, gregory.price@memverge.com, John Groves Subject: [RFC PATCH 12/20] famfs: Add inode_operations and file_system_type Date: Fri, 23 Feb 2024 11:41:56 -0600 Message-Id: X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- fs/famfs/famfs_inode.c | 132 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/fs/famfs/famfs_inode.c b/fs/famfs/famfs_inode.c index f98f82962d7b..ab46ec50b70d 100644 --- a/fs/famfs/famfs_inode.c +++ b/fs/famfs/famfs_inode.c @@ -85,6 +85,109 @@ static struct inode *famfs_get_inode( return inode; } +/*************************************************************************** + * famfs inode_operations: these are currently pretty much boilerplate + */ + +static const struct inode_operations famfs_file_inode_operations = { + /* All generic */ + .setattr = simple_setattr, + .getattr = simple_getattr, +}; + + +/* + * 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) { + 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); + + 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) { + int l = strlen(symname)+1; + + error = page_symlink(inode, symname, l); + 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; +} + +static const struct inode_operations famfs_dir_inode_operations = { + .create = famfs_create, + .lookup = simple_lookup, + .link = simple_link, + .unlink = simple_unlink, + .symlink = famfs_symlink, + .mkdir = famfs_mkdir, + .rmdir = simple_rmdir, + .mknod = famfs_mknod, + .rename = simple_rename, +}; + /********************************************************************************** * famfs super_operations * @@ -329,5 +432,34 @@ static int famfs_init_fs_context(struct fs_context *fc) return 0; } +static void famfs_kill_sb(struct super_block *sb) +{ + struct famfs_fs_info *fsi = sb->s_fs_info; + + mutex_lock(&famfs_context_mutex); + list_del(&fsi->fsi_list); + mutex_unlock(&famfs_context_mutex); + + if (fsi->bdev_handle) + bdev_release(fsi->bdev_handle); + if (fsi->dax_devp) + fs_put_dax(fsi->dax_devp, fsi); + if (fsi->dax_filp) /* This only happens if it's char dax */ + filp_close(fsi->dax_filp, NULL); + + if (fsi && fsi->rootdev) + kfree(fsi->rootdev); + kfree(fsi); + kill_litter_super(sb); +} + +#define MODULE_NAME "famfs" +static struct file_system_type famfs_fs_type = { + .name = MODULE_NAME, + .init_fs_context = famfs_init_fs_context, + .parameters = famfs_fs_parameters, + .kill_sb = famfs_kill_sb, + .fs_flags = FS_USERNS_MOUNT, +}; MODULE_LICENSE("GPL"); -- 2.43.0