zuf: ZUFS Zero-copy User-mode FileSystem
Subsystems (2)
cover zuf: ZUFS Zero-copy User-mode FileSystem
From: Boaz Harrosh <[email protected]>
I would please like to present the ZUFS file system and the Kernel code part in this patchset.
The Kernel code presented here can be found at:
https://github.com/NetApp/zufs-zuf
And the User-mode Server + example FSs here:
https://github.com/NetApp/zufs-zus
ZUFS - stands for Zero-copy User-mode FS
* It is geared towards true zero copy end to end of both data and meta data.
* It is geared towards very *low latency*, very high CPU locality, lock-less parallelism.
* Synchronous operations (for low latency)
* Numa awareness
Short description:
ZUFS is a from scratch implementation of a filesystem-in-user-space, which tries to address the above goals. from the get go it is aimed for pmem based FSs. But can easily support other type of FSs that can utilize x10 latency and parallelism improvements.
The novelty of this project is that the interface is designed with a modern multi-core NUMA machine in mind down to the ABI, so to reach these goals.
Please see first patch for License of this project
Current status: There are a couple of trivial open-source filesystem implementations and a full blown proprietary implementation from Netapp.
Together with the Kernel module submitted here the User-mode-Server and the zusFSs User-mode plugins, this code pass Netapp QA including xfstests + internal QA tests. And was released to costumers as Maxdata 1.2. So it is very stable.
In the git repository above there is also a backport for rhel 7.6. Including rpm packages for Kernel and Server components. (Also available evaluation licenses of Maxdata 1.2 for developers.
Please contact Amit Golander <[email protected]> if you need one)
Just to get some points across as I said this project is all about performance and low latency. Here below are some results I have run:
[fuse]
threads wr_iops wr_bw wr_lat
1 33606 134424 26.53226
2 57056 228224 30.38476
3 73142 292571 35.75727
4 88667 354668 40.12783
5 102280 409122 42.13261
6 110122 440488 48.29697
7 116561 466245 53.98572
8 129134 516539 55.6134
[fuse-splice]
threads wr_iops wr_bw wr_lat
1 39670 158682 21.8399
2 51100 204400 34.63294
3 62385 249542 39.28847
4 75220 300882 47.42344
5 84522 338088 52.97299
6 93042 372168 57.40804
7 97706 390825 63.04435
8 98034 392137 73.24263
[xfs-dax]
threads wr_iops wr_bw wr_lat
1 19449 77799 48.03282
2 37704 150819 37.2343
3 55415 221663 30.59375
4 72285 289142 26.08636
5 90348 361392 23.89037
6 103696 414787 22.38045
7 120638 482552 21.38869
8 134157 536630 21.1426
[Maxdata-1.2-zufs]
threads wr_iops wr_bw wr_lat
1 57506 230026 14.387113
2 98624 394498 16.790232
3 142276 569106 17.344622
4 187984 751936 17.527123
5 190304 761219 19.504314
6 221407 885628 20.862000
7 211579 846316 23.262040
8 246029 984116 24.630604
[*1]
These good results are when an mm patch is applied which introduces VM_LOCAL_CPU flag that eliminates vm_zap_ptes from scheduling on all CPUs when creating a per-cpu VMA.
This patch was not accepted by the Linux Kernel community and is not presented in this patchset. (Patch available for review on demand) But a few weeks from now I will submit some incremental changes to the code which will return the numbers to above, and even better for some benchmarks. (without the mm patch)
I have used an 8 way KVM-qemu with 2 NUMA nodes.
Running fio with 4k random writes O_DIRECT | O_SYNC to a DRAM simulated pmem. (memmap=! at grub), Fuse-fs was a memcpy same 4k null-FS fio was then run with more and more threads (see threads column) to test for scalability.
We are still > x2 slower than I would like to.
(Compared to an in-kernel pmem-base FS)
But I believe I can shave off another 1-2 us by farther optimizing the app-to-server thread switch by developing a new scheduler-object so to avoid going through the scheduler all together (and its locks) when switching VMs.
(Currently using couple of wait_queue_head_t with wait_event() calls
See relay.h in patches)
Please Review and ask any question big or trivial. I would love to iron this code, and submit it upstream.
Thank you for reading
Boaz
~~~~~~~~~~~~~~~~~~
Boaz Harrosh (17):
fs: Add the ZUF filesystem to the build + License
zuf: Preliminary Documentation
zuf: zuf-rootfs
zuf: zuf-core The ZTs
zuf: Multy Devices
zuf: mounting
zuf: Namei and directory operations
zuf: readdir operation
zuf: symlink
zuf: More file operation
zuf: Write/Read implementation
zuf: mmap & sync
zuf: ioctl implementation
zuf: xattr implementation
zuf: ACL support
zuf: Special IOCTL fadvise (TODO)
zuf: Support for dynamic-debug of zusFSs
Documentation/filesystems/zufs.txt | 351 ++++++++ fs/Kconfig | 1 + fs/Makefile | 1 + fs/zuf/Kconfig | 23 + fs/zuf/Makefile | 23 + fs/zuf/_extern.h | 166 ++++ fs/zuf/_pr.h | 62 ++ fs/zuf/acl.c | 281 +++++++ fs/zuf/directory.c | 167 ++++ fs/zuf/file.c | 527 ++++++++++++ fs/zuf/inode.c | 648 ++++++++++++++ fs/zuf/ioctl.c | 306 +++++++ fs/zuf/md.c | 761 +++++++++++++++++ fs/zuf/md.h | 318 +++++++ fs/zuf/md_def.h | 145 ++++ fs/zuf/mmap.c | 336 ++++++++ fs/zuf/module.c | 28 + fs/zuf/namei.c | 435 ++++++++++ fs/zuf/relay.h | 88 ++ fs/zuf/rw.c | 705 ++++++++++++++++ fs/zuf/super.c | 771 +++++++++++++++++ fs/zuf/symlink.c | 74 ++ fs/zuf/t1.c | 138 +++ fs/zuf/t2.c | 375 +++++++++ fs/zuf/t2.h | 68 ++ fs/zuf/xattr.c | 310 +++++++ fs/zuf/zuf-core.c | 1257 ++++++++++++++++++++++++++++ fs/zuf/zuf-root.c | 431 ++++++++++ fs/zuf/zuf.h | 414 +++++++++ fs/zuf/zus_api.h | 869 +++++++++++++++++++ 30 files changed, 10079 insertions(+) create mode 100644 Documentation/filesystems/zufs.txt create mode 100644 fs/zuf/Kconfig create mode 100644 fs/zuf/Makefile create mode 100644 fs/zuf/_extern.h create mode 100644 fs/zuf/_pr.h create mode 100644 fs/zuf/acl.c create mode 100644 fs/zuf/directory.c create mode 100644 fs/zuf/file.c create mode 100644 fs/zuf/inode.c create mode 100644 fs/zuf/ioctl.c create mode 100644 fs/zuf/md.c create mode 100644 fs/zuf/md.h create mode 100644 fs/zuf/md_def.h create mode 100644 fs/zuf/mmap.c create mode 100644 fs/zuf/module.c create mode 100644 fs/zuf/namei.c create mode 100644 fs/zuf/relay.h create mode 100644 fs/zuf/rw.c create mode 100644 fs/zuf/super.c create mode 100644 fs/zuf/symlink.c create mode 100644 fs/zuf/t1.c create mode 100644 fs/zuf/t2.c create mode 100644 fs/zuf/t2.h create mode 100644 fs/zuf/xattr.c create mode 100644 fs/zuf/zuf-core.c create mode 100644 fs/zuf/zuf-root.c create mode 100644 fs/zuf/zuf.h create mode 100644 fs/zuf/zus_api.h
Signature · 1 line
2.20.1
RFC PATCH 1/17 fs: Add the ZUF filesystem to the build + License
From: Boaz Harrosh <[email protected]>
This adds the ZUF filesystem-in-user_mode module to the fs/ build system.
Also added:
* fs/zuf/Kconfig
* fs/zuf/module.c - This file contains the LICENCE of zuf code base
* fs/zuf/Makefile - Rather empty Makefile with only module.c above
I add the fs/zuf/Makefile to demonstrate that at every patchset stage code still compiles and there are no external references outside of the code already submitted.
Off course only at the very last patch we have a working ZUF feeder
[LICENCE]
zuf.ko is a GPLv2 licensed project.
However the ZUS user mode Server is a BSD-3-Clause licensed project.
Therefor you will see that:
zus_api.h
md_def.h
md.h
These are common files with ZUS project are separately Licensed as BSD-3-Clause. Any contributor to these files should note that his code for these files is submitted as BSD-3-Clause.
This is for the obvious reasons as these define the API between Kernel an user-mode Server. It is the opinion of this project authors, as is of Linus that a pure API header is not governed by ANY license. But to make it clear.
--- fs/Kconfig | 1 + fs/Makefile | 1 + fs/zuf/Kconfig | 28 ++++++++++++++++++++ fs/zuf/Makefile | 14 ++++++++++ fs/zuf/module.c | 28 ++++++++++++++++++++ fs/zuf/zus_api.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 141 insertions(+) create mode 100644 fs/zuf/Kconfig create mode 100644 fs/zuf/Makefile create mode 100644 fs/zuf/module.c create mode 100644 fs/zuf/zus_api.h
fs/Kconfig +1 -0
@@ -254,6 +254,7 @@ source "fs/romfs/Kconfig" source "fs/pstore/Kconfig" source "fs/sysv/Kconfig" source "fs/ufs/Kconfig" +source "fs/zuf/Kconfig" source "fs/exofs/Kconfig" endif # MISC_FILESYSTEMS
fs/Makefile +1 -0
@@ -128,3 +128,4 @@ obj-y += exofs/ # Multiple modules obj-$(CONFIG_CEPH_FS) += ceph/ obj-$(CONFIG_PSTORE) += pstore/ obj-$(CONFIG_EFIVAR_FS) += efivarfs/ +obj-$(CONFIG_ZUF) += zuf/
fs/zuf/Kconfig new file +28 -0
@@ -0,0 +1,28 @@ +menuconfig ZUF + tristate "ZUF - Zero-copy User-mode Feeder" + depends on BLOCK + depends on ZONE_DEVICE + select CRC16 + select MEMCG + help + ZUFS Kernel part. + To enable say Y here. + + To compile this as a module, choose M here: the module will be + called zuf.ko + +if ZUF + +config ZUF_DEBUG + bool "ZUF: enable debug subsystems use" + depends on ZUF + default n + help + INTERNAL QA USE ONLY!!! DO NOT USE!!! + Please leave as N here + + This option adds some extra code that helps + in QA testing of the code. It may slow the + operation and produce bigger code + +endif
fs/zuf/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +# +# ZUF: Zero-copy User-mode Feeder +# +# Copyright (c) 2018 NetApp Inc. All rights reserved. +# +# ZUFS-License: GPL-2.0. See module.c for LICENSE details. +# +# Makefile for the Linux zufs Kernel Feeder. +# + +obj-$(CONFIG_ZUF) += zuf.o + +# Main FS +zuf-y += module.o
fs/zuf/module.c new file +28 -0
@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* zuf - Zero-copy User-mode Feeder +* +* Copyright (c) 2018 NetApp Inc. All rights reserved. +* +* This program is free software; you may redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 2 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ +#include <linux/module.h> + +#include "zus_api.h" + +MODULE_AUTHOR ("Boaz Harrosh <[email protected]>" ); +MODULE_AUTHOR ("Sagi Manole <[email protected]>" ); +MODULE_DESCRIPTION ("Zero-copy User-mode Feeder" ); +MODULE_LICENSE ("GPL" ); +MODULE_VERSION(__stringify(ZUFS_MAJOR_VERSION) "." + __stringify(ZUFS_MINOR_VERSION));
fs/zuf/zus_api.h new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
2.20.1
RFC PATCH 2/17 zuf: Preliminary Documentation
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
Adding Documentation/filesystems/zufs.txt
[v2]
Incorporated Randy's few comments.
Randy Please give it an harder review?
--- Documentation/filesystems/zufs.txt | 366 +++++++++++++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100644 Documentation/filesystems/zufs.txt
Documentation/filesystems/zufs.txt new file +366 -0
@@ -0,0 +1,366 @@ +ZUFS - Zero-copy User-mode FileSystem +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Trees: + git clone https://github.com/NetApp/zufs-zuf -b zuf-upstream + git clone https://github.com/NetApp/zufs-zus -b zus-github + +patches, comments, questions, requests to: + [email protected] + +Introduction: +~~~~~~~~~~~~~ + +ZUFS - stands for Zero-copy User-mode FS +▪ It is geared towards true zero copy end to end of both data and meta data. +▪ It is geared towards very *low latency*, very high CPU locality, lock-less + parallelism. +▪ Synchronous operations +▪ Numa awareness + + ZUFS is a, from scratch, implementation of a filesystem-in-user-space, which +tries to address the above goals. It is aimed for pmem based FSs. But can easily +support any other type of FSs that can utilize x10 latency and parallelism +improvements. + +Glossary and names: +~~~~~~~~~~~~~~~~~~~ + +ZUF - Zero-copy User-mode Feeder + zuf.ko is the Kernel VFS component. Its job is to interface with the Kernel + VFS and dispatch commands to a User-mode application Server. + Uptodate code is found at: + git clone https://github.com/NetApp/zufs-zuf -b zuf-upstream + +ZUS - Zero-copy User-mode Server + zufs utilizes a User-mode server application. That takes care of the detailed + communication protocol and correctness with the Kernel. + In turn it utilizes many zusFS Filesystem plugins to implement the actual + on disc Filesystem. + Uptodate code is found at: + git clone https://github.com/NetApp/zufs-zus -b zus-github + +zusFS - FS plugins + These are .so loadable modules that implement one or more Filesystem-types + (-t xyz). + The zus server communicates with the plugin via a set of function vectors + for the different operations. And establishes communication via defined + structures. + +Filesystem-type: + At startup zus registers with the Kernel one or more Filesystem-type(s) + Associated with the type is a unique type-name (mount -t foofs) + + different info about the fs, like a magic number and so on. + One Server can support many FS-types, in turn each FS-type can mount + multiple super-blocks, each supporting multiple devices. + +Device-Table (DT) - A zufs FS can support multiple devices + ZUF in Kernel may receive, like any mount command a block-device or none. + For the former if the specified FS-types states so in a special field. + The mount will look for a Device table. A list of devices in a specific + order sitting at some offset on the block-device. The system will then + proceed to open and own all these devices and associate them to the mounting + super-block. + If FS-type specifies a -1 at DT_offset then there is no device table + and a DT of a single device is created. (If we have no devices, none + is specified than we operate without any block devices. (Mount options give + some indication of the storage information)) + The device table has special consideration for pmem devices and will + present the all linear array of devices to zus, as one flat mmap space. + Alternatively all non-pmem devices are also provided an interface + with facility of data movement from pmem to slower devices. + A detailed NUMA info is exported to the Server for maximum utilization. + +pmem: + Multiple pmem devices are presented to the server as a single + linear file mmap. Something like /dev/dax. But it is strictly + available only to that specific super-block that owns it. + +dpp_t - Dual port pointer type + At some points in the protocol there are objects that return from zus + (The Server) to the Kernel via a dpp_t. This is a special kind of pointer + It is actually an offset 8 bytes aligned with the 3 low bits specifying + a pool code: [offset = dpp_t & ~0x7] [pool = dpp_t & 0x7] + pool == 0 means the offset is in pmem who's management is by zuf and + a full easy access is provided for zus. + + pool != 0 Is a pre-established file (up to 6 such files per sb) where + the zus has an mmap on the file and the Kernel can access that data + via an offset into the file. + pool == 7 denotes an offset into the application buffers associated + with the current IO. + All dpp_t objects life time rules are strictly defined. + Mainly the primary use of dpp_t is the on-pmem inode structure. Both + zus and zuf can access and change this structure. On any modification + the zus is called so to be notified of any changes, persistence. + More such objects are: Symlinks, xattrs, mmap-data-blocks etc... + +Relay-wait-object: + communication between Kernel and server are done via zus-threads that + sleep in Kernel (inside an IOCTL) and wait for commands. Once received + the IOCTL returns operation id executed and the return info is returned via + a new IOCTL call, which then waits for the next operation. + To wake up the sleeping thread we use a Relay-wait-object. Currently + it is two waitqueue_head(s) back to back. + In future we should investigate the use of that special binder object + that releases its thread time slice to the other thread without going through + the scheduler. + +ZT-threads-array: + The novelty of the zufs is the ZT-threads system. One thread or more is + pre-created for each active core in the system. + ▪ The thread is AFFINITY set for that single core only. + ▪ Special communication file per ZT (O_TMPFILE + IOCTL_ZUFS_INIT) + At initialization the ZT thread communicates through a ZT_INIT ioctl + and registers as the handler of that core (Channel) + ▪ ZT-vma - Mmap 4M vma zero copy communication area per ZT + Pre allocated vma is created into which will be mapped the application + or Kernel buffers for the current operation. + ▪ IOCTL_ZU_WAIT_OPT – threads sleeps in Kernel waiting for an operation + via the IOCTL_ZU_WAIT_OPT call. + + ▪ On an operation dispatch current CPU's ZT is selected, app pages mapped + into the ZT-vma. Server thread released with an operation to execute. + ▪ After execution, ZT returns to kernel (IOCTL_ZU_WAIT_OPT), app is released, + Server wait for new operation on that CPU. + ▪ Each ZT has a cyclic logic. Each call to IOCTL_ZU_WAIT_OPT from Server + returns the results of the previous operation, before going to sleep + waiting to receive a new operation. + zus zuf-zt application + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ---> IOCTL_ZU_WAIT_OPT if (app-waiting) + | wake-up-application -> return to app + | FS-WAIT + | | <- POSIX call + | V <- fs-wake-up(dispatch) + | <- return with new command + |--<- do_new_operation + +ZUS-mount-thread: + The system utilizes a single mount thread. (This thread is not affinity to any + core). + ▪ It will first Register all FS-types supported by this Server (By calling + all zusFS plugins to register their supported types). Once done + ▪ As above the thread sleeps in Kernel via the IOCTL_ZU_MOUNT call. + ▪ When the Kernel receives a mount request (vfs calles the fs_type->mount opt) + a mount is dispatched back to zus. + ▪ NOTE: That only on very first mount the above ZT-threads-array is created + the same array is then used for all super-blocks in the system + ▪ As part of the mount command in the context of this same mount-thread + a call to IOCTL_ZU_GRAB_PMEM will establish an interface to the pmem + Associated with this super_block + ▪ On return like above a new call to IOCTL_ZU_MOUNT will return info of the + mount before sleeping in kernel waiting for a new dispatch. All SB info + is provided to zuf, including the root inode info. Kernel then proceeds + to complete the mount call. + ▪ NOTE that since there is a single mount thread all FS-registration + super_block and pmem management are lockless. + +Philosophy of operations: +~~~~~~~~~~~~~~~~~~~~~~~~~ + +1. [zuf-root] + +On module load (zuf.ko) A special pseudo FS is mounted on /sys/fs/zuf. This is +called zuf-root. +The zuf-root has no visible files. All communication is done via special-files. +special-files are open(O_TMPFILE) and establish a special role via an +IOCTL. +All communications with the server are done via the zuf-root. Each root owns +many FS-types and each FS-type owns many super-blocks of this type. All Sharing +the same communication channels. +Since all FS-type Servers live in the same zus application address space, at +times. If the administrator wants to separate between different servers, he/she +can mount a new zuf-root and point a new server instance on that new mount, +registering other FS-types on that other instance. The all communication array +will then be duplicated as well. +(Otherwise pointing a new server instance on a busy root will return an error) + +2. [zus server start] + ▪ On load all configured zusFS plugins are loaded. + ▪ The Server starts by starting a single mount thread. + ▪ It than proceeds to register with Kernel all FS-types it will support. + (This is done on the single mount thread, so all FS-registration and + mount/umount operate in a single thread and therefor need not any locks) + ▪ Sleeping in the Kernel on a special-file of that zuf-root. waiting for a mount + command. + +3. [mount -t xyz] + [In Kernel] + ▪ If xyz was registered above as part of the Server startup. the regular + mount command will come to the zuf module with a zuf_mount() call. with + the xyz-FS-info. In turn this points to a zuf-root. + ▪ Code than proceed to load a device-table of devices as specified above. + It then establishes an multi_devices object with a specific pmem_id. + ▪ It proceeds to call mount_bdev. Always with the same main-device + thous fully sporting automatic bind mounts. Even if different + devices are given to the mount command. + ▪ In zuf_fill_super it will then dispatch (awaken) the mount thread + specifying two parameters. One the FS-type to mount, and then + the pmem_id Associated with this super_block. + + [In zus] + ▪ A zus_super_block_info is allocated. + ▪ zus calls PMEM_GRAB(pmem_id) to establish a direct mapping to its + pmem devices. On return we have full access to our PMEM + + ▪ ZT-threads-array + If this is the first mount the all ZT-threads-array is created and + established. The mount thread will wait until all zt-threads finished + initialization and ready to rock. + ▪ Root-zus_inode is loaded and is returned to kernel + ▪ More info about the mount like block sizes and so on are returned to kernel. + + [In Kernel] + The zuf_fill_super is finalized vectors established and we have a new + super_block ready for operations. + +4. An FS operation like create or WRITE/READ and so on arrives from application + via VFS. Eventually an Operation is dispatched to zus: + ▪ A special per-operation descriptor is filled up with all parameters. + ▪ A current CPU channel is grabbed. the operation descriptor is put on + that channel (ZT). Including get_user_pages or Kernel-pages associated + with this OPT. + ▪ The ZT is awaken, app thread put to sleep. + ▪ In ZT context pages are mapped to that ZT-vma. This is so we are sure + the map is only on a single core. And no other core's TLB is affected. + (This here is the all performance secret) + ▪ ZT thread is returned to user-space. + ▪ In ZT context the zus Server calls the appropriate zusFS->operation + vector. Output params filled. + ▪ zus calls again with an IOCTL_ZU_WAIT_OPT with the same descriptor + to return the requested info. + ▪ At Kernel (zuf) the app thread is awaken with the results, and the + ZT thread goes back to sleep waiting a new operation. + + ZT rules: + A ZT thread must not return back to Kernel. One exception is locks + if needed it might sleep waiting for a lock. In which case we will see that + the same CPU channel is reentered via another application and/or thread. + But now that CPU channel is taken. What we do is we utilize a few channels + (ZTs) per core and the threads may grab another channel. But this only + postpones the problem on a busy contended system, all such channels will be + consumed. If all channels are taken the application thread is put on a busy + scheduling wait until a channel can be grabbed. + Therefor Server must not sleep on a ZT. If it needs such a sleeping operation + it will return -EAGAIN to zuf. The app is kept sleeping the operation is put + on an asynchronous Q and the ZT freed for foreground operation. At some point + when the server completes the delayed operation it will complete notify + the Kernel with a special async cookie. And the app will be awakened. + (Here too we utilize pre allocated asyc channels and vmas. If all channels + are busy, application is kept sleeping waiting its free slot turn) + +4. On umount the operation is reversed and all resources are torn down. +5. In case of an application or Server crash, all resources are Associated + with files, on file_release these resources are caught and freed. + +Objects and life-time +~~~~~~~~~~~~~~~~~~~~~ + +Each Kernel object type has an assosiated zus Server object type who's life +time is governed by the life-time of the Kernel object. Therefor the Server's +job is easy because it need not establish any object caches / hashes and so on. + +Inside zus all objects are allocated by the zusFS plugin. So in turn it can +allocate a bigger space for its own private data and access it via the +container_off() coding pattern. So when I say below a zus-object I mean both +zus public part + zusFS private part of the same object. + +All operations return a User-mode pointer that are opaque to the the Kernel +code, they are just a cookie which is returned back to zus, when needed. +At times when we want the Kernel to have direct access to a zus object like +zus_inode, along with the cookie we also return a dpp_t, with a defined +structure. + +Kernel object | zus object | Kernel access (via dpp_t) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +zuf_fs_type + file_system_type | zus_fs_info | no + +zuf_sb_info + super_block | zus_sb_info | no + +zuf_inode_info | | + vfs_inode | zus_inode_info | no + zus_inode * | zus_inode * | yes + synlink * | char-array | yes + xattr** | zus_xattr | yes + +When a Kernel object's time is to die, a final call to zus is +dispatched so the associated object can also be freed. Which means +that on memory pressure when object caches are evicted also the zus +memory resources are freed. + + +How to use zufs: +~~~~~~~~~~~~~~~~ + +The most updated documentation of how to use the latest code bases +is the script (set of scripts) at fs/do-zu/zudo on the zus git tree + +We the developers at Netapp use this script to mount and test our +latest code. So any new Secret will be found in these scripts. Please +read them as the ultimate source of how to operate things. + +TODO: We are looking for exports in system-d and udev to properly +integrate these tools into a destro. + +We assume you cloned these git trees: +[]$ mkdir zufs; cd zufs +[]$ git clone https://github.com/NetApp/zufs-zuf -b zuf-upstream +[]$ git clone https://github.com/NetApp/zufs-zuf -b zus-github + +This will create the following trees +zufs/zus - Source code for Server +zufs/zuf - Linux Kernel source tree to compile and install on your machine + +Also specifically: +zufs/zus/fs/do-zu/zudo - script Documenting how to run things + +[]$ cd zuf + +First time +[] ../zus/fs/do-zu/zudo +this will create a file: + ../zus/fs/do-zu/zu.conf + +Edit this file for your environment. Devices, mount-point and so on. +On first run an example file will be created for you. Fill in the +blanks. Most params can stay as is in most cases + +Now lest start running: + +[1]$ ../zus/fs/do-zu/zudo mkfs +This will run the proper mkfs command selected at zu.conf file +with the proper devices. + +[2]$ ../zus/fs/do-zu/zudo zuf-insmod +This loads the zuf.ko module + +[3]$ ../zus/fs/do-zu/zudo zuf-root +This mounts the zuf-root FS above on /sys/fs/zuf (automatically created above) + +[4]$ ../zus/fs/do-zu/zudo zus-up +This runs the zus daemon in the background + +[5]$ ../zus/fs/do-zu/zudo mount +This mount the mkfs FS above on the specified dir in zu.conf + +To run all the 5 commands above at once do: +[]$ ../zus/fs/do-zu/zudo up + +To undo all the above in reverse order do: +[]$ ../zus/fs/do-zu/zudo down + +And the most magic command is: +[]$ ../zus/fs/do-zu/zudo again +Will do a "down", then update-mods, then "up" +(update-mods is a special script to copy the latest compiled binaries) + +Now you are ready for some: +[]$ ../zus/fs/do-zu/zudo xfstest +xfstests is assumed to be installed in the regular /opt/xfstests dir + +Again please see inside the scripts what each command does +these scripts are the ultimate Documentation, do not believe +anything I'm saying here. (Because it is outdated by now)
Signature · 1 line
2.20.1
RFC PATCH 3/17 zuf: zuf-rootfs
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
zuf-root is a psuedo FS that the zus Server communicates through, registers new file-systems. receives new mount requests.
In this patch we have the bring up of that special FS.
The principal communication with zuf-rootfs is done by doing an open(O_TMPFILE) invoking some IOCTL_XXX on the file. This establishes a zuf_special_file type of object attached to the "file *" and by that defining special behavior for that object (Picture will be clearer in future patches) Otherwise zuf-rootfs is not an FS at all. And has no viewable files
The zuf-rootfs (mount -t zuf) is usually by default mounted on /sys/fs/zuf. If an admin wants to run more server applications (Note that each server application supports many types of FSs) He/she can mount a second instance of -t zuf and point the new Server to it.
(Otherwise a second instance attempting to communicate with a
busy zuf will fail)
TODO: How to trigger a first mount on module_load. Currently admin needs to manually "mount -t zuf none /sys/fs/zuf"
--- fs/zuf/Makefile | 4 + fs/zuf/_extern.h | 38 +++++ fs/zuf/_pr.h | 43 ++++++ fs/zuf/super.c | 53 +++++++ fs/zuf/zuf-core.c | 60 ++++++++ fs/zuf/zuf-root.c | 347 ++++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/zuf.h | 108 +++++++++++++++ fs/zuf/zus_api.h | 36 +++++ 8 files changed, 689 insertions(+) create mode 100644 fs/zuf/_extern.h create mode 100644 fs/zuf/_pr.h create mode 100644 fs/zuf/super.c create mode 100644 fs/zuf/zuf-core.c create mode 100644 fs/zuf/zuf-root.c create mode 100644 fs/zuf/zuf.h
fs/zuf/Makefile +4 -0
@@ -10,5 +10,9 @@ obj-$(CONFIG_ZUF) += zuf.o +# ZUF core +zuf-y += zuf-core.o zuf-root.o + # Main FS +zuf-y += super.o zuf-y += module.o
fs/zuf/_extern.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2018 NetApp Inc. All rights reserved. +* +* ZUFS-License: GPL-2.0. See module.c for LICENSE details. +* +* Authors: +* Boaz Harrosh <[email protected]> +* Sagi Manole <[email protected]>" +*/ + +#ifndef __ZUF_EXTERN_H__ +#define __ZUF_EXTERN_H__ +/* +* DO NOT INCLUDE this file directly, it is included by zuf.h +* It is here because zuf.h got to big +*/ + +/* +* extern functions declarations +*/ + +/* super.c */ +int zuf_init_inodecache (void ); +void zuf_destroy_inodecache (void ); + +struct dentry *zuf_mount (struct file_system_type *fs_type,int flags, +const char *dev_name,void *data); + +/* zuf-core.c */ +long zufc_ioctl (struct file *filp,unsigned int cmd,ulong arg); +int zufc_release (struct inode *inode,struct file *file); +int zufc_mmap (struct file *file,struct vm_area_struct *vma); + +/* zuf-root.c */ +int zufr_register_fs (struct super_block *sb,struct zufs_ioc_register_fs *rfs); + +#endif /*ndef __ZUF_EXTERN_H__*/
fs/zuf/_pr.h new file +43 -0
43 lines not on this page · raw message
fs/zuf/super.c new file +53 -0
53 lines not on this page · raw message
fs/zuf/zuf-core.c new file +60 -0
60 lines not on this page · raw message
fs/zuf/zuf-root.c new file +347 -0
347 lines not on this page · raw message
fs/zuf/zuf.h new file +108 -0
108 lines not on this page · raw message
fs/zuf/zus_api.h +36 -0
@@ -66,4 +66,40 @@#endif /* ndef __KERNEL__ */ +struct zufs_ioc_hdr { +__u32 err;/* IN/OUT must be first */ +__u16 in_len;/* How much to be copied *to* zus */ +__u16 out_max;/* Max receive buffer at dispatch caller */ +__u16 out_start;/* Start of output parameters (to caller) */ +__u16 out_len;/* How much to be copied *from* zus to caller */ +/* can be modified by zus */ +__u32 operation;/* One of e_zufs_operation */ +__u32 offset;/* Start of user buffer in ZT mmap */ +__u32 len;/* Len of user buffer in ZT mmap */ +}; + +/* Register FS */ +/* A cookie from user-mode given in register_fs_info */ +struct zus_fs_info ; +struct zufs_ioc_register_fs { +struct zufs_ioc_hdr hdr; +struct zus_fs_info *zus_zfi; +struct register_fs_info { +/* IN */ +char fsname[16 ];/* Only 4 chars and a NUL please */ +__u32 FS_magic;/* This is the FS's version && magic */ +__u32 FS_ver_major;/* on disk, not the zuf-to-zus version*/ +__u32 FS_ver_minor;/* (See also struct md_dev_table) */ + +__u8 notused[3 ]; +__u64 dt_offset; + +__u32 s_time_gran; +__u32 def_mode; +__u64 s_maxbytes; + + } rfi; +}; +#define ZU_IOC_REGISTER_FS _IOWR('Z', 10, struct zufs_ioc_register_fs) +#endif /* _LINUX_ZUFS_API_H */
Signature · 1 line
2.20.1
RFC PATCH 4/17 zuf: zuf-core The ZTs
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
zuf-core established the communication channels with the ZUS User Mode Server.
In this patch we have the core communication mechanics. Which is the Novelty of this project.
(See previous submitted documentation for more info)
Users will come later in the patchset
--- fs/zuf/_extern.h | 22 + fs/zuf/_pr.h | 4 + fs/zuf/relay.h | 88 ++++ fs/zuf/zuf-core.c | 1016 ++++++++++++++++++++++++++++++++++++++++++++- fs/zuf/zuf-root.c | 7 + fs/zuf/zuf.h | 46 ++ fs/zuf/zus_api.h | 185 +++++++++ 7 files changed, 1367 insertions(+), 1 deletion(-) create mode 100644 fs/zuf/relay.h
fs/zuf/_extern.h +22 -0
@@ -28,10 +28,32 @@ struct dentry *zuf_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data);/* zuf-core.c */ +int zufc_zts_init (struct zuf_root_info *zri);/* Some private types in core */ +void zufc_zts_fini (struct zuf_root_info *zri); +long zufc_ioctl (struct file *filp,unsigned int cmd,ulong arg);int zufc_release (struct inode *inode,struct file *file);int zufc_mmap (struct file *file,struct vm_area_struct *vma); +int __zufc_dispatch_mount (struct zuf_root_info *zri, +enum e_mount_operation op, +struct zufs_ioc_mount *zim); +int zufc_dispatch_mount (struct zuf_root_info *zri,struct zus_fs_info *zus_zfi, +enum e_mount_operation operation, +struct zufs_ioc_mount *zim); + +const char *zuf_op_name (enum e_zufs_operation op); +int __zufc_dispatch (struct zuf_root_info *zri,struct zuf_dispatch_op *zdo); +static inline +int zufc_dispatch (struct zuf_root_info *zri,struct zufs_ioc_hdr *hdr, +struct page **pages,uint nump) +{ +struct zuf_dispatch_op zdo; + +zuf_dispatch_init (&zdo, hdr, pages, nump); +return __zufc_dispatch (zri, &zdo); +} +/* zuf-root.c */ int zufr_register_fs (struct super_block *sb,struct zufs_ioc_register_fs *rfs);
fs/zuf/_pr.h +4 -0
@@ -39,5 +39,9 @@/* ~~~ channel prints ~~~ */ #define zuf_dbg_err(s, args ...) zuf_chan_debug("error", s, ##args) +#define zuf_dbg_vfs(s, args ...) zuf_chan_debug("vfs ", s, ##args) +#define zuf_dbg_core(s, args ...) zuf_chan_debug("core ", s, ##args) +#define zuf_dbg_zus(s, args ...) zuf_chan_debug("zusdg", s, ##args) +#define zuf_dbg_verbose(s, args ...) zuf_chan_debug("d-oto", s, ##args)#endif /* define __ZUF_PR_H__ */
fs/zuf/relay.h new file +88 -0
88 lines not on this page · raw message
fs/zuf/zuf-core.c +1015 -1
1,046 lines not on this page · raw message
fs/zuf/zuf-root.c +7 -0
@@ -227,6 +227,7 @@ static void zufr_put_super(struct super_block *sb) {struct zuf_root_info *zri =ZRI (sb); +zufc_zts_fini (zri);_unregister_all_fses (zri);zuf_info ("zuf_root umount\n" );
@@ -282,10 +283,16 @@ static int zufr_fill_super(struct super_block *sb, void *data, int silent) root_i->i_fop = &zufr_file_dir_operations; root_i->i_op = &zufr_inode_operations; +spin_lock_init (&zri->mount.lock);mutex_init (&zri->sbl_lock); +relay_init (&zri->mount.relay);INIT_LIST_HEAD (&zri->fst_list);INIT_LIST_HEAD (&zri->pmem_list); + err =zufc_zts_init (zri); +if (unlikely (err)) +return err;/* put will be called we have a root */ +return 0 ; }
fs/zuf/zuf.h +46 -0
67 lines not on this page · raw message
fs/zuf/zus_api.h +185 -0
195 lines not on this page · raw message
Signature · 1 line
2.20.1
RFC PATCH 5/17 zuf: Multy Devices
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
ZUFS supports Multiple block devices per super_block. This here is the devices handling code. At the output a single multi_devices (md.h) object is associated with the mounting super_block.
There are three mode of operations:
* mount with out a device (mount -t FOO none /somepath)
* A single device - The FS stated register_fs_info->dt_offset==-1 No checks are made by Kernel, the single bdev is registered with Kernel's mount_bdev. It is up to the zusFS to check validity
* Multy devices - The FS stated register_fs_info->dt_offset==X
This mode is the main of this patch.
A single device is given on the mount command line. At register_fs_info->dt_offset of this device we look for a zufs_dev_table structure. After all the checks we look there at the device list and open all devices. Any one of the devices may be given on command line. But they will always be opened in DT(Device Table) order. The Device table has the notion of two types of bdevs:
T1 devices - are pmem devices capable of direct_access
T2 devices - are none direct_access devices
All t1 devices are presented as one linear array. in DT order In t1.c we mmap this space for the server to directly access pmem. (In the proper persistent way)
[We do not support any direct_access device, we only support
pmem(s) where the all device can be addressed by a single physical/virtual address. This is checked before mount]
The T2 devices are also grabbed and owned by the super_block A later API will enable the Server to write or transfer buffers from T1 to T2 in a very efficient manner. Also presented as a single linear array in DT order.
Both kind of devices are NUMA aware and the NUMA info is presented to the zusFS for optimal allocation and access.
--- fs/zuf/Makefile | 3 + fs/zuf/_extern.h | 3 + fs/zuf/_pr.h | 11 + fs/zuf/md.c | 764 ++++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/md.h | 318 +++++++++++++++++++ fs/zuf/md_def.h | 145 +++++++++ fs/zuf/t1.c | 138 +++++++++ fs/zuf/t2.c | 375 +++++++++++++++++++++++ fs/zuf/t2.h | 68 +++++ fs/zuf/zuf-core.c | 87 ++++++ fs/zuf/zuf.h | 39 +++ fs/zuf/zus_api.h | 18 ++ 12 files changed, 1969 insertions(+) create mode 100644 fs/zuf/md.c create mode 100644 fs/zuf/md.h create mode 100644 fs/zuf/md_def.h create mode 100644 fs/zuf/t1.c create mode 100644 fs/zuf/t2.c create mode 100644 fs/zuf/t2.h
fs/zuf/Makefile +3 -0
@@ -10,6 +10,9 @@ obj-$(CONFIG_ZUF) += zuf.o +# Infrastructure +zuf-y += md.o t1.o t2.o + # ZUF core zuf-y += zuf-core.o zuf-root.o
fs/zuf/_extern.h +3 -0
@@ -57,4 +57,7 @@ int zufc_dispatch(struct zuf_root_info *zri, struct zufs_ioc_hdr *hdr,/* zuf-root.c */ int zufr_register_fs (struct super_block *sb,struct zufs_ioc_register_fs *rfs); +/* t1.c */ +int zuf_pmem_mmap (struct file *file,struct vm_area_struct *vma); +#endif /*ndef __ZUF_EXTERN_H__*/
fs/zuf/_pr.h +11 -0
@@ -40,8 +40,19 @@/* ~~~ channel prints ~~~ */ #define zuf_dbg_err(s, args ...) zuf_chan_debug("error", s, ##args) #define zuf_dbg_vfs(s, args ...) zuf_chan_debug("vfs ", s, ##args) +#define zuf_dbg_t1(s, args ...) zuf_chan_debug("t1 ", s, ##args) +#define zuf_dbg_t2(s, args ...) zuf_chan_debug("t2dbg", s, ##args) +#define zuf_dbg_t2_rw(s, args ...) zuf_chan_debug("t2grw", s, ##args) #define zuf_dbg_core(s, args ...) zuf_chan_debug("core ", s, ##args) #define zuf_dbg_zus(s, args ...) zuf_chan_debug("zusdg", s, ##args) #define zuf_dbg_verbose(s, args ...) zuf_chan_debug("d-oto", s, ##args) +#define md_err zuf_err +#define md_warn zuf_warn +#define md_err_cnd zuf_err_cnd +#define md_warn_cnd zuf_warn_cnd +#define md_dbg_err zuf_dbg_err +#define md_dbg_verbose zuf_dbg_verbose + +#endif /* define __ZUF_PR_H__ */
fs/zuf/md.c new file +764 -0
764 lines not on this page · raw message
fs/zuf/md.h new file +318 -0
318 lines not on this page · raw message
fs/zuf/md_def.h new file +145 -0
145 lines not on this page · raw message
fs/zuf/t1.c new file +138 -0
138 lines not on this page · raw message
fs/zuf/t2.c new file +375 -0
375 lines not on this page · raw message
fs/zuf/t2.h new file +68 -0
68 lines not on this page · raw message
fs/zuf/zuf-core.c +87 -0
105 lines not on this page · raw message
fs/zuf/zuf.h +39 -0
@@ -29,6 +29,8 @@#include "relay.h" #include "_pr.h" +#include "md.h" +#include "t2.h" enum zlfs_e_special_file { zlfs_e_zt =1 ,
@@ -42,6 +44,14 @@ struct zuf_special_file {struct file *file; }; +/* Our special md structure */ +struct zuf_pmem { +struct multi_devices md;/* must be first */ +struct list_head list; +struct zuf_special_file hdr; +uint pmem_id; +}; +/* This is the zuf-root.c mini filesystem */ struct zuf_root_info { struct __mount_thread_info {
@@ -94,6 +104,35 @@ static inline void zuf_add_fs_type(struct zuf_root_info *zri,list_add (&zft->list, &zri->fst_list); } +static inline void zuf_add_pmem (struct zuf_root_info *zri, +struct multi_devices *md) +{ +struct zuf_pmem *z_pmem = (void *)md; + + z_pmem->pmem_id = ++zri->next_pmem_id;/* Avoid 0 id */ + +/* Unlocked for now only one mount-thread with zus */ +INIT_LIST_HEAD (&z_pmem->list); +list_add (&z_pmem->list, &zri->pmem_list); +} + +static inline void zuf_rm_pmem (struct multi_devices *md) +{ +struct zuf_pmem *z_pmem = (void *)md; + +if (z_pmem->pmem_id)/* We avoided 0 id */ +list_del_init (&z_pmem->list); +} + +static inline uint zuf_pmem_id (struct multi_devices *md) +{ + struct zuf_pmem *z_pmem = container_of(md, struct zuf_pmem, md); + +return z_pmem->pmem_id; +} + +// void zuf_del_fs_type(struct zuf_root_info *zri, struct zuf_fs_type *zft); +/* * ZUF per-inode data in memory */
fs/zuf/zus_api.h +18 -0
@@ -19,6 +19,8 @@#include <stddef.h> #include <linux/statfs.h> +#include "md_def.h" +/* * Version rules: * This is the zus-to-zuf API version. And not the Filesystem
@@ -74,6 +76,10 @@*/ #define EZUF_RETRY_DONE 540 + +/* All device sizes offsets must align on 2M */ +#define ZUFS_ALLOC_MASK (1024 * 1024 * 2 - 1) +/** * zufs dual port memory * This is a special type of offset to either memory or persistent-memory,
@@ -221,6 +227,18 @@ struct zufs_ioc_numa_map { };#define ZU_IOC_NUMA_MAP _IOWR('Z', 12, struct zufs_ioc_numa_map) +struct zufs_ioc_pmem { +/* Set by zus */ +struct zufs_ioc_hdr hdr; +__u32 pmem_kern_id; + +/* Returned to zus */ +struct md_dev_table mdt; + +}; +/* GRAB is never ungrabed umount or file close cleans it all */ +#define ZU_IOC_GRAB_PMEM _IOWR('Z', 13, struct zufs_ioc_pmem) +/* ZT init */ enum {ZUFS_MAX_ZT_CHANNELS =64 };
Signature · 1 line
2.20.1
RFC PATCH 6/17 zuf: mounting
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
In this patch we already establish a mounted filesystem.
These are the steps for mounting a zufs Filesystem:
* All devices (Single or DT) are opened and established in an md object. This md-object is given an pmem-id
* mount_bdev is called with the main (first) device, in turn fill_supper is called.
* fill_supper despatches a mount_operation(register_fs_info) to the server with the pmem-id of the md-object above.
* The Server at the zus mount routine. Will first thing do a GRAB_PMEM(pmem-id) ioctl call to establish a special filehandle through which it will have full access to the all of its pmem space. With that it will call the zusFS to continue to inspect the content of the pmem and mount the FS.
* On return from mount the zusFS returns the root inode info
* fill_supper continues to create a root vfs-inode and returns successfully.
* We now have a mounted super_block, with corresponding super_block objects in the Server.
--- fs/zuf/Makefile | 2 +- fs/zuf/_extern.h | 4 + fs/zuf/inode.c | 22 ++ fs/zuf/super.c | 623 ++++++++++++++++++++++++++++++++++++++++++++++- fs/zuf/zuf.h | 122 ++++++++++ fs/zuf/zus_api.h | 57 +++++ 6 files changed, 828 insertions(+), 2 deletions(-) create mode 100644 fs/zuf/inode.c
fs/zuf/Makefile +1 -1
@@ -17,5 +17,5 @@ zuf-y += md.o t1.o t2.o zuf-y += zuf-core.o zuf-root.o # Main FS -zuf-y += super.o +zuf-y += super.o inode.o zuf-y += module.o
fs/zuf/_extern.h +4 -0
@@ -20,6 +20,10 @@* extern functions declarations */ +/* inode.c */ +struct inode *zuf_iget (struct super_block *sb,struct zus_inode_info *zus_ii, +zu_dpp_t _zi,bool *exist); +/* super.c */ int zuf_init_inodecache (void );void zuf_destroy_inodecache (void );
fs/zuf/inode.c new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* BRIEF DESCRIPTION +* +* Inode methods (allocate/free/read/write). +* +* Copyright (c) 2018 NetApp Inc. All rights reserved. +* +* ZUFS-License: GPL-2.0. See module.c for LICENSE details. +* +* Authors: +* Boaz Harrosh <[email protected]> +* Sagi Manole <[email protected]>" +*/ + +#include "zuf.h" + +struct inode *zuf_iget (struct super_block *sb,struct zus_inode_info *zus_ii, +zu_dpp_t _zi,bool *exist) +{ +return ERR_PTR (-ENOTSUPP ); +}
fs/zuf/super.c +622 -1
638 lines not on this page · raw message
fs/zuf/zuf.h +122 -0
145 lines not on this page · raw message
fs/zuf/zus_api.h +57 -0
86 lines not on this page · raw message
Signature · 1 line
2.20.1
RFC PATCH 8/17 zuf: readdir operation
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
Establish protocol with Server for readdir
--- fs/zuf/_extern.h | 3 ++ fs/zuf/directory.c | 69 +++++++++++++++++++++++++++++++++ fs/zuf/zuf-core.c | 1 + fs/zuf/zus_api.h | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 169 insertions(+)
fs/zuf/_extern.h +3 -0
@@ -39,6 +39,9 @@ int zuf_setattr(struct dentry *dentry, struct iattr *attr);int zuf_getattr (const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags);void zuf_set_inode_flags (struct inode *inode,struct zus_inode *zi); +bool zuf_dir_emit (struct super_block *sb,struct dir_context *ctx, +ulong ino,const char *name,int length); +/* rw.c */ int zuf_trim_edge (struct inode *inode,ulong filepos,uint len);
fs/zuf/directory.c +69 -0
80 lines not on this page · raw message
fs/zuf/zuf-core.c +1 -0
@@ -773,6 +773,7 @@ const char *zuf_op_name(enum e_zufs_operation op)CASE_ENUM_NAME (ZUFS_OP_ADD_DENTRY );CASE_ENUM_NAME (ZUFS_OP_REMOVE_DENTRY );CASE_ENUM_NAME (ZUFS_OP_RENAME ); +CASE_ENUM_NAME (ZUFS_OP_READDIR );CASE_ENUM_NAME (ZUFS_OP_SETATTR );CASE_ENUM_NAME (ZUFS_OP_BREAK );default :
fs/zuf/zus_api.h +96 -0
108 lines not on this page · raw message
Signature · 1 line
2.20.1
RFC PATCH 7/17 zuf: Namei and directory operations
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
Introducing Creation/deletion of files
Directory add/remove
Other namei operations
--- fs/zuf/Makefile | 3 +- fs/zuf/_extern.h | 38 +++ fs/zuf/directory.c | 94 +++++++ fs/zuf/file.c | 26 ++ fs/zuf/inode.c | 599 ++++++++++++++++++++++++++++++++++++++++++++- fs/zuf/namei.c | 402 ++++++++++++++++++++++++++++++ fs/zuf/rw.c | 25 ++ fs/zuf/super.c | 2 + fs/zuf/zuf-core.c | 9 + fs/zuf/zuf.h | 83 +++++++ fs/zuf/zus_api.h | 100 ++++++++ 11 files changed, 1379 insertions(+), 2 deletions(-) create mode 100644 fs/zuf/directory.c create mode 100644 fs/zuf/file.c create mode 100644 fs/zuf/namei.c create mode 100644 fs/zuf/rw.c
fs/zuf/Makefile +2 -1
@@ -17,5 +17,6 @@ zuf-y += md.o t1.o t2.o zuf-y += zuf-core.o zuf-root.o # Main FS -zuf-y += super.o inode.o +zuf-y += rw.o +zuf-y += super.o inode.o directory.o namei.o file.o zuf-y += module.o
fs/zuf/_extern.h +38 -0
@@ -20,9 +20,28 @@* extern functions declarations */ +/* directory.c */ +int zuf_add_dentry (struct inode *dir,struct qstr *str,struct inode *inode); +int zuf_remove_dentry (struct inode *dir,struct qstr *str,struct inode *inode); +/* inode.c */ +int zuf_evict_dispatch (struct super_block *sb,struct zus_inode_info *zus_ii, +int operation,uint flags);struct inode *zuf_iget (struct super_block *sb,struct zus_inode_info *zus_ii,zu_dpp_t _zi,bool *exist); +void zuf_evict_inode (struct inode *inode); +struct inode *zuf_new_inode (struct inode *dir,umode_t mode, +const struct qstr *qstr,const char *symname, +ulong rdev_or_isize,bool tmpfile); +int zuf_write_inode (struct inode *inode,struct writeback_control *wbc); +int zuf_update_time (struct inode *inode,struct timespec64 *time,int flags); +int zuf_setattr (struct dentry *dentry,struct iattr *attr); +int zuf_getattr (const struct path *path,struct kstat *stat, +u32 request_mask,unsigned int flags); +void zuf_set_inode_flags (struct inode *inode,struct zus_inode *zi); + +/* rw.c */ +int zuf_trim_edge (struct inode *inode,ulong filepos,uint len);/* super.c */ int zuf_init_inodecache (void );
@@ -64,4 +83,23 @@ int zufr_register_fs(struct super_block *sb, struct zufs_ioc_register_fs *rfs);/* t1.c */ int zuf_pmem_mmap (struct file *file,struct vm_area_struct *vma); +/* +* Inodes and files operations +*/ + +/* dir.c */ +extern const struct file_operations zuf_dir_operations; + +/* file.c */ +extern const struct inode_operations zuf_file_inode_operations; +extern const struct file_operations zuf_file_operations; + +/* inode.c */ +extern const struct address_space_operations zuf_aops; +void zuf_zii_sync (struct inode *inode,bool sync_nlink); + +/* namei.c */ +extern const struct inode_operations zuf_dir_inode_operations; +extern const struct inode_operations zuf_special_inode_operations; +#endif /*ndef __ZUF_EXTERN_H__*/
fs/zuf/directory.c new file +94 -0
94 lines not on this page · raw message
fs/zuf/file.c new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* BRIEF DESCRIPTION +* +* File operations for files. +* +* Copyright (c) 2018 NetApp Inc. All rights reserved. +* +* ZUFS-License: GPL-2.0. See module.c for LICENSE details. +* +* Authors: +* Boaz Harrosh <[email protected]> +* Sagi Manole <[email protected]>" +*/ + +#include "zuf.h" + +const struct file_operations zuf_file_operations = { + .open = generic_file_open, +}; + +const struct inode_operations zuf_file_inode_operations = { + .setattr = zuf_setattr, + .getattr = zuf_getattr, + .update_time = zuf_update_time, +};
fs/zuf/inode.c +598 -1
608 lines not on this page · raw message
fs/zuf/namei.c new file +402 -0
402 lines not on this page · raw message
fs/zuf/rw.c new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* BRIEF DESCRIPTION +* +* Read/Write operations. +* +* Copyright (c) 2018 NetApp Inc. All rights reserved. +* +* ZUFS-License: GPL-2.0. See module.c for LICENSE details. +* +* Authors: +* Boaz Harrosh <[email protected]> +*/ +#include <linux/fadvise.h> +#include <linux/uio.h> +#include <linux/delay.h> + +#include "zuf.h" +#include "t2.h" + +/* ZERO a part of a single block. len does not cross a block boundary */ +int zuf_trim_edge (struct inode *inode,ulong filepos,uint len) +{ +return -EIO ; +}
fs/zuf/super.c +2 -0
@@ -616,6 +616,8 @@ void zuf_destroy_inodecache(void)static struct super_operations zuf_sops = { .alloc_inode = zuf_alloc_inode, .destroy_inode = zuf_destroy_inode, + .write_inode = zuf_write_inode, + .evict_inode = zuf_evict_inode, .put_super = zuf_put_super, .freeze_fs = zuf_update_s_wtime, .unfreeze_fs = zuf_update_s_wtime,
fs/zuf/zuf-core.c +9 -0
@@ -765,6 +765,15 @@ const char *zuf_op_name(enum e_zufs_operation op) {#define CASE_ENUM_NAME (e) case e: return #eswitch (op) { +CASE_ENUM_NAME (ZUFS_OP_STATFS ); +CASE_ENUM_NAME (ZUFS_OP_NEW_INODE ); +CASE_ENUM_NAME (ZUFS_OP_FREE_INODE ); +CASE_ENUM_NAME (ZUFS_OP_EVICT_INODE ); +CASE_ENUM_NAME (ZUFS_OP_LOOKUP ); +CASE_ENUM_NAME (ZUFS_OP_ADD_DENTRY ); +CASE_ENUM_NAME (ZUFS_OP_REMOVE_DENTRY ); +CASE_ENUM_NAME (ZUFS_OP_RENAME ); +CASE_ENUM_NAME (ZUFS_OP_SETATTR );CASE_ENUM_NAME (ZUFS_OP_BREAK );default :return "UNKNOWN" ;
fs/zuf/zuf.h +83 -0
107 lines not on this page · raw message
fs/zuf/zus_api.h +100 -0
119 lines not on this page · raw message
Signature · 1 line
2.20.1
RFC PATCH 9/17 zuf: symlink
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
--- fs/zuf/Makefile | 2 +- fs/zuf/_extern.h | 7 +++++ fs/zuf/inode.c | 7 +++++ fs/zuf/namei.c | 27 ++++++++++++++++++ fs/zuf/symlink.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/zuf-core.c | 1 + fs/zuf/zus_api.h | 1 + 7 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 fs/zuf/symlink.c
fs/zuf/Makefile +1 -1
@@ -18,5 +18,5 @@ zuf-y += zuf-core.o zuf-root.o # Main FS zuf-y += rw.o -zuf-y += super.o inode.o directory.o namei.o file.o +zuf-y += super.o inode.o directory.o namei.o file.o symlink.o zuf-y += module.o
fs/zuf/_extern.h +7 -0
@@ -42,6 +42,10 @@ void zuf_set_inode_flags(struct inode *inode, struct zus_inode *zi);bool zuf_dir_emit (struct super_block *sb,struct dir_context *ctx,ulong ino,const char *name,int length); +/* symlink.c */ +uint zuf_prepare_symname (struct zufs_ioc_new_inode *ioc_new_inode, +const char *symname,ulong len,struct page *pages[2 ]); +/* rw.c */ int zuf_trim_edge (struct inode *inode,ulong filepos,uint len);
@@ -105,4 +109,7 @@ void zuf_zii_sync(struct inode *inode, bool sync_nlink);extern const struct inode_operations zuf_dir_inode_operations;extern const struct inode_operations zuf_special_inode_operations; +/* symlink.c */ +extern const struct inode_operations zuf_symlink_inode_operations; +#endif /*ndef __ZUF_EXTERN_H__*/
fs/zuf/inode.c +7 -0
@@ -82,6 +82,9 @@ static void _set_inode_from_zi(struct inode *inode, struct zus_inode *zi) inode->i_op = &zuf_dir_inode_operations; inode->i_fop = &zuf_dir_operations;break ; +case S_IFLNK : + inode->i_op = &zuf_symlink_inode_operations; +break ;case S_IFBLK :case S_IFCHR :case S_IFIFO :
@@ -357,6 +360,10 @@ struct inode *zuf_new_inode(struct inode *dir, umode_t mode,if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode) ||S_ISFIFO (inode->i_mode) ||S_ISSOCK (inode->i_mode)) {init_special_inode (inode, mode, rdev_or_isize); + }else if (symname) { + inode->i_size = rdev_or_isize; + nump =zuf_prepare_symname (&ioc_new_inode, symname, + rdev_or_isize, pages); } err =_set_zi_from_inode (dir, &ioc_new_inode.zi, inode);
fs/zuf/namei.c +27 -0
@@ -164,6 +164,32 @@ static int zuf_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)return 0 ; } +static int zuf_symlink (struct inode *dir,struct dentry *dentry, +const char *symname) +{ +struct inode *inode; +ulong len; + +zuf_dbg_vfs ("[%ld] de->name=%s symname=%s\n" , + dir->i_ino, dentry->d_name.name, symname); + + len =strlen (symname); +if (len +1 >ZUFS_MAX_SYMLINK ) +return -ENAMETOOLONG ; + + inode =zuf_new_inode (dir,S_IFLNK |S_IRWXUGO , &dentry->d_name, + symname, len, false); +if (IS_ERR (inode)) +return PTR_ERR (inode); + + inode->i_op = &zuf_symlink_inode_operations; + inode->i_mapping->a_ops = &zuf_aops; + +_instantiate_unlock (dentry, inode); + +return 0 ; +} +static int zuf_link (struct dentry *dest_dentry,struct inode *dir,struct dentry *dentry) {
@@ -385,6 +411,7 @@ const struct inode_operations zuf_dir_inode_operations = { .lookup = zuf_lookup, .link = zuf_link, .unlink = zuf_unlink, + .symlink = zuf_symlink, .mkdir = zuf_mkdir, .rmdir = zuf_rmdir, .mknod = zuf_mknod,
fs/zuf/symlink.c new file +73 -0
73 lines not on this page · raw message
fs/zuf/zuf-core.c +1 -0
@@ -774,6 +774,7 @@ const char *zuf_op_name(enum e_zufs_operation op)CASE_ENUM_NAME (ZUFS_OP_REMOVE_DENTRY );CASE_ENUM_NAME (ZUFS_OP_RENAME );CASE_ENUM_NAME (ZUFS_OP_READDIR ); +CASE_ENUM_NAME (ZUFS_OP_GET_SYMLINK );CASE_ENUM_NAME (ZUFS_OP_SETATTR );CASE_ENUM_NAME (ZUFS_OP_BREAK );default :
fs/zuf/zus_api.h +1 -0
@@ -338,6 +338,7 @@ enum e_zufs_operation {ZUFS_OP_RENAME ,ZUFS_OP_READDIR , +ZUFS_OP_GET_SYMLINK ,ZUFS_OP_SETATTR , ZUFS_OP_BREAK, /* Kernel telling Server to exit */
Signature · 1 line
2.20.1
RFC PATCH 10/17 zuf: More file operation
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
Add more file operation.
Some are calling stubs in other files
--- fs/zuf/_extern.h | 4 + fs/zuf/file.c | 429 ++++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/rw.c | 12 ++ fs/zuf/zuf-core.c | 4 + fs/zuf/zus_api.h | 45 +++++ 5 files changed, 494 insertions(+)
fs/zuf/_extern.h +4 -0
@@ -48,6 +48,10 @@ uint zuf_prepare_symname(struct zufs_ioc_new_inode *ioc_new_inode,/* rw.c */ +ssize_t zuf_rw_read_iter (struct super_block *sb,struct inode *inode, +struct kiocb *kiocb,struct iov_iter *ii); +ssize_t zuf_rw_write_iter (struct super_block *sb,struct inode *inode, +struct kiocb *kiocb,struct iov_iter *ii);int zuf_trim_edge (struct inode *inode,ulong filepos,uint len);/* super.c */
fs/zuf/file.c +429 -0
443 lines not on this page · raw message
fs/zuf/rw.c +12 -0
@@ -23,3 +23,15 @@ int zuf_trim_edge(struct inode *inode, ulong filepos, uint len) {return -EIO ; } + +ssize_t zuf_rw_read_iter (struct super_block *sb,struct inode *inode, +struct kiocb *kiocb,struct iov_iter *ii) +{ +return -EIO ; +} + +ssize_t zuf_rw_write_iter (struct super_block *sb,struct inode *inode, +struct kiocb *kiocb,struct iov_iter *ii) +{ +return -EIO ; +}
fs/zuf/zuf-core.c +4 -0
@@ -774,8 +774,12 @@ const char *zuf_op_name(enum e_zufs_operation op)CASE_ENUM_NAME (ZUFS_OP_REMOVE_DENTRY );CASE_ENUM_NAME (ZUFS_OP_RENAME );CASE_ENUM_NAME (ZUFS_OP_READDIR ); +CASE_ENUM_NAME (ZUFS_OP_CLONE ); +CASE_ENUM_NAME (ZUFS_OP_COPY );CASE_ENUM_NAME (ZUFS_OP_GET_SYMLINK );CASE_ENUM_NAME (ZUFS_OP_SETATTR ); +CASE_ENUM_NAME (ZUFS_OP_FALLOCATE ); +CASE_ENUM_NAME (ZUFS_OP_LLSEEK );CASE_ENUM_NAME (ZUFS_OP_BREAK );default :return "UNKNOWN" ;
fs/zuf/zus_api.h +45 -0
60 lines not on this page · raw message
Signature · 1 line
2.20.1
RFC PATCH 11/17 zuf: Write/Read implementation
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
The dispatch to the server can operate on buffers up to 4 Mega bytes. Any bigger operations are split up and dispatched at this size.
Also if a multy-segments aio is used each segment is dispatched on its own. (TODO this can be easily fixed with sg operations)
On write if any mmaped buffers changed, for example new allocated holes do to this write or a previous mmaped COW was written. A range subset of the written range can be returned for the Kernel to call mapping_unmap on.
rw.c here also includes some operations for mmap. Will be used in next patch.
--- fs/zuf/_extern.h | 13 +- fs/zuf/_pr.h | 1 + fs/zuf/rw.c | 562 +++++++++++++++++++++++++++++++++++++++++++++- fs/zuf/zuf-core.c | 79 ++++++- fs/zuf/zus_api.h | 191 ++++++++++++++++ 5 files changed, 841 insertions(+), 5 deletions(-)
fs/zuf/_extern.h +12 -1
@@ -46,13 +46,21 @@ bool zuf_dir_emit(struct super_block *sb, struct dir_context *ctx,uint zuf_prepare_symname (struct zufs_ioc_new_inode *ioc_new_inode,const char *symname,ulong len,struct page *pages[2 ]); -/* rw.c */ +int _zuf_get_put_block (struct zuf_sb_info *sbi,struct zuf_inode_info *zii, +enum e_zufs_operation op,int rw,ulong index, +struct zufs_ioc_IO *get_block); +int zuf_rw_read_page (struct zuf_sb_info *sbi,struct inode *inode, +struct page *page,u64 filepos);ssize_t zuf_rw_read_iter (struct super_block *sb,struct inode *inode,struct kiocb *kiocb,struct iov_iter *ii);ssize_t zuf_rw_write_iter (struct super_block *sb,struct inode *inode,struct kiocb *kiocb,struct iov_iter *ii);int zuf_trim_edge (struct inode *inode,ulong filepos,uint len); +int zuf_iom_execute_sync (struct super_block *sb,struct inode *inode, +__u64 *iom_e,uint iom_n); +int zuf_iom_execute_async (struct super_block *sb,struct zus_iomap_build *iomb, +__u64 *iom_e_user,uint iom_n);/* super.c */ int zuf_init_inodecache (void );
@@ -61,6 +69,9 @@ void zuf_destroy_inodecache(void);struct dentry *zuf_mount (struct file_system_type *fs_type,int flags,const char *dev_name,void *data); +struct super_block *zuf_sb_from_id (struct zuf_root_info *zri,__u64 sb_id, +struct zus_sb_info *zus_sbi); +/* zuf-core.c */ int zufc_zts_init (struct zuf_root_info *zri);/* Some private types in core */ void zufc_zts_fini (struct zuf_root_info *zri);
fs/zuf/_pr.h +1 -0
@@ -40,6 +40,7 @@/* ~~~ channel prints ~~~ */ #define zuf_dbg_err(s, args ...) zuf_chan_debug("error", s, ##args) #define zuf_dbg_vfs(s, args ...) zuf_chan_debug("vfs ", s, ##args) +#define zuf_dbg_rw(s, args ...) zuf_chan_debug("rw ", s, ##args) #define zuf_dbg_t1(s, args ...) zuf_chan_debug("t1 ", s, ##args) #define zuf_dbg_t2(s, args ...) zuf_chan_debug("t2dbg", s, ##args) #define zuf_dbg_t2_rw(s, args ...) zuf_chan_debug("t2grw", s, ##args)
fs/zuf/rw.c +559 -3
579 lines not on this page · raw message
fs/zuf/zuf-core.c +78 -1
109 lines not on this page · raw message
fs/zuf/zus_api.h +191 -0
207 lines not on this page · raw message
Signature · 1 line
2.20.1
RFC PATCH 12/17 zuf: mmap & sync
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
On page-fault call the zusFS for the page information. We always mmap pmem pages directly. (No page cache)
With write-mmap and pmem. We need to keep track of dirty inodes and call the zusFS when one of the sync variants are called.
This is because the Server will need to do a cl_flush on all dirty pages.
If we did not have write-mmaped called on the inode we do nothing on sync.
--- fs/zuf/Makefile | 2 +- fs/zuf/_extern.h | 10 ++ fs/zuf/_pr.h | 1 + fs/zuf/file.c | 65 +++++++++ fs/zuf/inode.c | 10 ++ fs/zuf/mmap.c | 339 ++++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/super.c | 91 +++++++++++++ fs/zuf/zuf-core.c | 2 + fs/zuf/zuf.h | 3 + fs/zuf/zus_api.h | 9 ++ 10 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 fs/zuf/mmap.c
fs/zuf/Makefile +1 -1
@@ -17,6 +17,6 @@ zuf-y += md.o t1.o t2.o zuf-y += zuf-core.o zuf-root.o # Main FS -zuf-y += rw.o +zuf-y += rw.o mmap.o zuf-y += super.o inode.o directory.o namei.o file.o symlink.o zuf-y += module.o
fs/zuf/_extern.h +10 -0
@@ -46,6 +46,10 @@ bool zuf_dir_emit(struct super_block *sb, struct dir_context *ctx,uint zuf_prepare_symname (struct zufs_ioc_new_inode *ioc_new_inode,const char *symname,ulong len,struct page *pages[2 ]); + +/* mmap.c */ +int zuf_file_mmap (struct file *file,struct vm_area_struct *vma); +/* rw.c */ int _zuf_get_put_block(struct zuf_sb_info *sbi, struct zuf_inode_info *zii, enum e_zufs_operation op, int rw, ulong index,
@@ -61,11 +65,17 @@ int zuf_iom_execute_sync(struct super_block *sb, struct inode *inode, __u64 *iom_e, uint iom_n);int zuf_iom_execute_async (struct super_block *sb,struct zus_iomap_build *iomb,__u64 *iom_e_user,uint iom_n); +/* file.c */ +int zuf_isync (struct inode *inode,loff_t start,loff_t end,int datasync); +/* super.c */ int zuf_init_inodecache (void );void zuf_destroy_inodecache (void ); +void zuf_sync_inc (struct inode *inode); +void zuf_sync_dec (struct inode *inode,ulong write_unmapped); +struct dentry *zuf_mount (struct file_system_type *fs_type,int flags,const char *dev_name,void *data);
fs/zuf/_pr.h +1 -0
@@ -45,6 +45,7 @@ #define zuf_dbg_t2(s, args ...) zuf_chan_debug("t2dbg", s, ##args) #define zuf_dbg_t2_rw(s, args ...) zuf_chan_debug("t2grw", s, ##args) #define zuf_dbg_core(s, args ...) zuf_chan_debug("core ", s, ##args) +#define zuf_dbg_mmap(s, args ...) zuf_chan_debug("mmap ", s, ##args) #define zuf_dbg_zus(s, args ...) zuf_chan_debug("zusdg", s, ##args) #define zuf_dbg_verbose(s, args ...) zuf_chan_debug("d-oto", s, ##args)
fs/zuf/file.c +65 -0
78 lines not on this page · raw message
fs/zuf/inode.c +10 -0
@@ -270,6 +270,7 @@ void zuf_evict_inode(struct inode *inode) {struct super_block *sb = inode->i_sb;struct zuf_inode_info *zii =ZUII (inode); +int write_mapped;if (!inode->i_nlink) {if (unlikely (!zii->zi)) {
@@ -312,6 +313,15 @@ void zuf_evict_inode(struct inode *inode) zii->zero_page =NULL ; } +/* ZUS on evict has synced all mmap dirty pages, YES? */ + write_mapped =atomic_read (&zii->write_mapped); +if (unlikely (write_mapped || !list_empty (&zii->i_mmap_dirty))) { +zuf_dbg_mmap ("[%ld] !!!! write_mapped=%d list_empty=%d\n" , + inode->i_ino, write_mapped, +list_empty (&zii->i_mmap_dirty)); +zuf_sync_dec (inode, write_mapped); + } +clear_inode (inode); }
fs/zuf/mmap.c new file +339 -0
339 lines not on this page · raw message
fs/zuf/super.c +91 -0
109 lines not on this page · raw message
fs/zuf/zuf-core.c +2 -0
@@ -781,8 +781,10 @@ const char *zuf_op_name(enum e_zufs_operation op)CASE_ENUM_NAME (ZUFS_OP_WRITE );CASE_ENUM_NAME (ZUFS_OP_GET_BLOCK );CASE_ENUM_NAME (ZUFS_OP_PUT_BLOCK ); +CASE_ENUM_NAME (ZUFS_OP_MMAP_CLOSE );CASE_ENUM_NAME (ZUFS_OP_GET_SYMLINK );CASE_ENUM_NAME (ZUFS_OP_SETATTR ); +CASE_ENUM_NAME (ZUFS_OP_SYNC );CASE_ENUM_NAME (ZUFS_OP_FALLOCATE );CASE_ENUM_NAME (ZUFS_OP_LLSEEK );CASE_ENUM_NAME (ZUFS_OP_BREAK );
fs/zuf/zuf.h +3 -0
@@ -158,6 +158,9 @@ struct zuf_inode_info {/* Stuff for mmap write */ struct rw_semaphore in_sync; +struct list_head i_mmap_dirty; +atomic_t write_mapped; +atomic_t vma_count;struct page *zero_page;/* TODO: Remove */ /* cookies from Server */
fs/zuf/zus_api.h +9 -0
@@ -344,8 +344,10 @@ enum e_zufs_operation {ZUFS_OP_WRITE ,ZUFS_OP_GET_BLOCK ,ZUFS_OP_PUT_BLOCK , +ZUFS_OP_MMAP_CLOSE ,ZUFS_OP_GET_SYMLINK ,ZUFS_OP_SETATTR , +ZUFS_OP_SYNC ,ZUFS_OP_FALLOCATE , ZUFS_OP_LLSEEK,
@@ -516,6 +518,13 @@ static inline bool zufs_zde_emit(struct zufs_readdir_iter *rdi, __u64 ino,return true; } +struct zufs_ioc_mmap_close { +struct zufs_ioc_hdr hdr; +/* IN */ +struct zus_inode_info *zus_ii; +__u64 rw;/* Some flags + READ or WRITE */ +}; +/* ZUFS_OP_GET_SYMLINK */ struct zufs_ioc_get_link {struct zufs_ioc_hdr hdr;
Signature · 1 line
2.20.1
RFC PATCH 13/17 zuf: ioctl implementation
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
* support for some generic IOCTLs:
FS_IOC_GETFLAGS, FS_IOC_SETFLAGS, FS_IOC_GETVERSION, FS_IOC_SETVERSION
* Simple support for zusFS defined IOCTLs
We only support flat structures
(no emmbedded pointers within the IOCTL structures) We try to deduce the size of the IOCTL from the _IOC_SIZE(cmd) If zusFS needs a bigger copy it will send a retry with the new size. So bad defined IOCTLs always do 2 trips to userland
--- fs/zuf/Makefile | 2 +- fs/zuf/_extern.h | 5 + fs/zuf/directory.c | 4 + fs/zuf/file.c | 4 + fs/zuf/ioctl.c | 282 +++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/zuf-core.c | 1 + fs/zuf/zus_api.h | 16 +++ 7 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 fs/zuf/ioctl.c
fs/zuf/Makefile +1 -1
@@ -17,6 +17,6 @@ zuf-y += md.o t1.o t2.o zuf-y += zuf-core.o zuf-root.o # Main FS -zuf-y += rw.o mmap.o +zuf-y += rw.o mmap.o ioctl.o zuf-y += super.o inode.o directory.o namei.o file.o symlink.o zuf-y += module.o
fs/zuf/_extern.h +5 -0
@@ -46,6 +46,11 @@ bool zuf_dir_emit(struct super_block *sb, struct dir_context *ctx,uint zuf_prepare_symname (struct zufs_ioc_new_inode *ioc_new_inode,const char *symname,ulong len,struct page *pages[2 ]); +/* ioctl.c */ +long zuf_ioctl (struct file *filp,uint cmd,ulong arg); +#ifdef CONFIG_COMPAT +long zuf_compat_ioctl (struct file *file,uint cmd,ulong arg); +#endif /* mmap.c */ int zuf_file_mmap (struct file *file,struct vm_area_struct *vma);
fs/zuf/directory.c +4 -0
@@ -160,4 +160,8 @@ const struct file_operations zuf_dir_operations = { .read = generic_read_dir, .iterate_shared = zuf_readdir, .fsync = noop_fsync, + .unlocked_ioctl = zuf_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = zuf_compat_ioctl, +#endif };
fs/zuf/file.c +4 -0
@@ -507,7 +507,11 @@ const struct file_operations zuf_file_operations = { .fsync = zuf_fsync, .flush = zuf_flush, .release = zuf_file_release, + .unlocked_ioctl = zuf_ioctl, .fallocate = zuf_fallocate, +#ifdef CONFIG_COMPAT + .compat_ioctl = zuf_compat_ioctl, +#endif .copy_file_range = zuf_copy_file_range, .remap_file_range = zuf_clone_file_range, };
fs/zuf/ioctl.c new file +282 -0
282 lines not on this page · raw message
fs/zuf/zuf-core.c +1 -0
@@ -787,6 +787,7 @@ const char *zuf_op_name(enum e_zufs_operation op)CASE_ENUM_NAME (ZUFS_OP_SYNC );CASE_ENUM_NAME (ZUFS_OP_FALLOCATE );CASE_ENUM_NAME (ZUFS_OP_LLSEEK ); +CASE_ENUM_NAME (ZUFS_OP_IOCTL );CASE_ENUM_NAME (ZUFS_OP_BREAK );default :return "UNKNOWN" ;
fs/zuf/zus_api.h +16 -0
@@ -350,6 +350,7 @@ enum e_zufs_operation {ZUFS_OP_SYNC ,ZUFS_OP_FALLOCATE ,ZUFS_OP_LLSEEK , +ZUFS_OP_IOCTL ,ZUFS_OP_BREAK ,/* Kernel telling Server to exit */ ZUFS_OP_MAX_OPT,
@@ -586,6 +587,21 @@ struct zufs_ioc_seek {__u64 offset_out; }; +/* ZUFS_OP_IOCTL */ +struct zufs_ioc_ioctl { +struct zufs_ioc_hdr hdr; +/* IN */ +struct zus_inode_info *zus_ii; +__u32 cmd; +__u64 time; + +/* OUT */ +union { +__u32 new_size; +char arg[0 ]; + }; +}; +/* ~~~~ io_map structures && IOCTL(s) ~~~~ */ /* * These set of structures and helpers are used in return of zufs_ioc_IO and
Signature · 1 line
2.20.1
RFC PATCH 14/17 zuf: xattr implementation
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
We establish the usual dispatch to user-mode. For get and set. Since the buffers are variable length we utilize the zdo->overflow_handler for the extra copy from Server. (see also zuf-core.c)
--- fs/zuf/Makefile | 1 + fs/zuf/_extern.h | 10 ++ fs/zuf/_pr.h | 1 + fs/zuf/file.c | 1 + fs/zuf/inode.c | 3 +- fs/zuf/namei.c | 2 + fs/zuf/super.c | 1 + fs/zuf/symlink.c | 1 + fs/zuf/xattr.c | 314 ++++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/zuf-core.c | 3 + fs/zuf/zuf.h | 7 ++ fs/zuf/zus_api.h | 22 ++++ 12 files changed, 365 insertions(+), 1 deletion(-) create mode 100644 fs/zuf/xattr.c
fs/zuf/Makefile +1 -0
@@ -17,6 +17,7 @@ zuf-y += md.o t1.o t2.o zuf-y += zuf-core.o zuf-root.o # Main FS +zuf-y += xattr.o zuf-y += rw.o mmap.o ioctl.o zuf-y += super.o inode.o directory.o namei.o file.o symlink.o zuf-y += module.o
fs/zuf/_extern.h +10 -0
@@ -73,6 +73,16 @@ int zuf_iom_execute_async(struct super_block *sb, struct zus_iomap_build *iomb,/* file.c */ int zuf_isync (struct inode *inode,loff_t start,loff_t end,int datasync); +/* xattr.c */ +int zuf_initxattrs (struct inode *inode,const struct xattr *xattr_array, +void *fs_info); +ssize_t __zuf_getxattr (struct inode *inode,int type,const char *name, +void *buffer,size_t size); +int __zuf_setxattr (struct inode *inode,int type,const char *name, +const void *value,size_t size,int flags); +ssize_t zuf_listxattr (struct dentry *dentry,char *buffer,size_t size); +extern const struct xattr_handler *zuf_xattr_handlers[]; +/* super.c */ int zuf_init_inodecache (void );
fs/zuf/_pr.h +1 -0
@@ -42,6 +42,7 @@ #define zuf_dbg_vfs(s, args ...) zuf_chan_debug("vfs ", s, ##args) #define zuf_dbg_rw(s, args ...) zuf_chan_debug("rw ", s, ##args) #define zuf_dbg_t1(s, args ...) zuf_chan_debug("t1 ", s, ##args) +#define zuf_dbg_xattr(s, args ...) zuf_chan_debug("xattr", s, ##args) #define zuf_dbg_t2(s, args ...) zuf_chan_debug("t2dbg", s, ##args) #define zuf_dbg_t2_rw(s, args ...) zuf_chan_debug("t2grw", s, ##args) #define zuf_dbg_core(s, args ...) zuf_chan_debug("core ", s, ##args)
fs/zuf/file.c +1 -0
@@ -521,4 +521,5 @@ const struct inode_operations zuf_file_inode_operations = { .getattr = zuf_getattr, .update_time = zuf_update_time, .fiemap = tozu_fiemap, + .listxattr = zuf_listxattr, };
fs/zuf/inode.c +2 -1
@@ -361,7 +361,8 @@ struct inode *zuf_new_inode(struct inode *dir, umode_t mode,zuf_dbg_verbose ("inode=%p name=%s\n" , inode, qstr->name); - err =security_inode_init_security (inode, dir, qstr,NULL ,NULL ); + err =security_inode_init_security (inode, dir, qstr, zuf_initxattrs, +NULL );if (err && err != -EOPNOTSUPP ) goto fail;
fs/zuf/namei.c +2 -0
@@ -420,10 +420,12 @@ const struct inode_operations zuf_dir_inode_operations = { .setattr = zuf_setattr, .getattr = zuf_getattr, .update_time = zuf_update_time, + .listxattr = zuf_listxattr, };const struct inode_operations zuf_special_inode_operations = { .setattr = zuf_setattr, .getattr = zuf_getattr, .update_time = zuf_update_time, + .listxattr = zuf_listxattr, };
fs/zuf/super.c +1 -0
@@ -414,6 +414,7 @@ static int zuf_fill_super(struct super_block *sb, void *data, int silent) sb->s_flags |=MS_NOSEC | (ioc_mount->zmi.acl_on ?SB_POSIXACL :0 ); sb->s_op = &zuf_sops; + sb->s_xattr = zuf_xattr_handlers; root_i =zuf_iget (sb, ioc_mount->zmi.zus_ii, ioc_mount->zmi._zi, &exist);
fs/zuf/symlink.c +1 -0
@@ -70,4 +70,5 @@ const struct inode_operations zuf_symlink_inode_operations = { .update_time = zuf_update_time, .setattr = zuf_setattr, .getattr = zuf_getattr, + .listxattr = zuf_listxattr, };
fs/zuf/xattr.c new file +314 -0
314 lines not on this page · raw message
fs/zuf/zuf-core.c +3 -0
@@ -788,6 +788,9 @@ const char *zuf_op_name(enum e_zufs_operation op)CASE_ENUM_NAME (ZUFS_OP_FALLOCATE );CASE_ENUM_NAME (ZUFS_OP_LLSEEK );CASE_ENUM_NAME (ZUFS_OP_IOCTL ); +CASE_ENUM_NAME (ZUFS_OP_XATTR_GET ); +CASE_ENUM_NAME (ZUFS_OP_XATTR_SET ); +CASE_ENUM_NAME (ZUFS_OP_XATTR_LIST );CASE_ENUM_NAME (ZUFS_OP_BREAK );default :return "UNKNOWN" ;
fs/zuf/zuf.h +7 -0
@@ -328,6 +328,13 @@ static inline void *zuf_dpp_t_addr(struct super_block *sb, zu_dpp_t v)return md_addr_verify (SBI (sb)->md,zu_dpp_t_val (v)); } +/* xattr types */ +enum {ZUF_XF_SECURITY =1 , +ZUF_XF_SYSTEM =2 , +ZUF_XF_TRUSTED =3 , +ZUF_XF_USER =4 , +}; +enum big_alloc_type { ba_stack, ba_kmalloc, ba_vmalloc }; static inline
fs/zuf/zus_api.h +22 -0
@@ -351,6 +351,9 @@ enum e_zufs_operation {ZUFS_OP_FALLOCATE ,ZUFS_OP_LLSEEK ,ZUFS_OP_IOCTL , +ZUFS_OP_XATTR_GET , +ZUFS_OP_XATTR_SET , +ZUFS_OP_XATTR_LIST ,ZUFS_OP_BREAK ,/* Kernel telling Server to exit */ ZUFS_OP_MAX_OPT,
@@ -602,6 +605,25 @@ struct zufs_ioc_ioctl { }; }; +/* xattr ioc_flags */ +#define ZUFS_XATTR_SET_EMPTY (1 << 0) +#define ZUFS_XATTR_TRUSTED (1 << 1) + +/* ZUFS_OP_XATTR */ +struct zufs_ioc_xattr { +struct zufs_ioc_hdr hdr; +/* IN */ +struct zus_inode_info *zus_ii; +__u32 flags; +__u32 type; +__u16 name_len; +__u16 ioc_flags; + +/* OUT */ +__u32 user_buf_size; +char buf[0 ]; +} __packed; +/* ~~~~ io_map structures && IOCTL(s) ~~~~ */ /* * These set of structures and helpers are used in return of zufs_ioc_IO and
Signature · 1 line
2.20.1
RFC PATCH 15/17 zuf: ACL support
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
The ACL support is all in Kernel. There is no new API with zusFS.
We define the internal structure of the ACL inside an opec xattr and store via the xattr zus_api.
TODO:
Future FSs that has their own ACL on-disk-format, Or Network zusFS that have their own verifiers for the ACL will need to establish an alternative API for the acl.
--- fs/zuf/Makefile | 2 +- fs/zuf/_extern.h | 9 ++ fs/zuf/_pr.h | 1 + fs/zuf/acl.c | 283 +++++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/file.c | 2 + fs/zuf/inode.c | 11 ++ fs/zuf/namei.c | 4 + fs/zuf/zuf.h | 6 + 8 files changed, 317 insertions(+), 1 deletion(-) create mode 100644 fs/zuf/acl.c
fs/zuf/Makefile +1 -1
@@ -17,7 +17,7 @@ zuf-y += md.o t1.o t2.o zuf-y += zuf-core.o zuf-root.o # Main FS -zuf-y += xattr.o +zuf-y += acl.o xattr.o zuf-y += rw.o mmap.o ioctl.o zuf-y += super.o inode.o directory.o namei.o file.o symlink.o zuf-y += module.o
fs/zuf/_extern.h +9 -0
@@ -83,6 +83,15 @@ int __zuf_setxattr(struct inode *inode, int type, const char *name,ssize_t zuf_listxattr (struct dentry *dentry,char *buffer,size_t size);extern const struct xattr_handler *zuf_xattr_handlers[]; +/* acl.c */ +int zuf_set_acl (struct inode *inode,struct posix_acl *acl,int type); +struct posix_acl *zuf_get_acl (struct inode *inode,int type); +int zuf_acls_create_pre (struct inode *dir,struct inode *inode, +struct posix_acl **user_acl); +int zuf_acls_create_post (struct inode *dir,struct inode *inode, +struct posix_acl *acl); +extern const struct xattr_handler zuf_acl_access_xattr_handler; +extern const struct xattr_handler zuf_acl_default_xattr_handler;/* super.c */ int zuf_init_inodecache (void );
fs/zuf/_pr.h +1 -0
@@ -43,6 +43,7 @@ #define zuf_dbg_rw(s, args ...) zuf_chan_debug("rw ", s, ##args) #define zuf_dbg_t1(s, args ...) zuf_chan_debug("t1 ", s, ##args) #define zuf_dbg_xattr(s, args ...) zuf_chan_debug("xattr", s, ##args) +#define zuf_dbg_acl(s, args ...) zuf_chan_debug("acl ", s, ##args) #define zuf_dbg_t2(s, args ...) zuf_chan_debug("t2dbg", s, ##args) #define zuf_dbg_t2_rw(s, args ...) zuf_chan_debug("t2grw", s, ##args) #define zuf_dbg_core(s, args ...) zuf_chan_debug("core ", s, ##args)
fs/zuf/acl.c new file +283 -0
283 lines not on this page · raw message
fs/zuf/file.c +2 -0
@@ -521,5 +521,7 @@ const struct inode_operations zuf_file_inode_operations = { .getattr = zuf_getattr, .update_time = zuf_update_time, .fiemap = tozu_fiemap, + .get_acl = zuf_get_acl, + .set_acl = zuf_set_acl, .listxattr = zuf_listxattr, };
fs/zuf/inode.c +11 -0
@@ -342,6 +342,7 @@ struct inode *zuf_new_inode(struct inode *dir, umode_t mode, .flags = tmpfile ? ZI_TMPFILE : 0, .str.len = qstr->len, }; +struct posix_acl *acl =NULL ;struct inode *inode;struct zus_inode *zi =NULL ;struct page *pages[2 ];
@@ -366,6 +367,10 @@ struct inode *zuf_new_inode(struct inode *dir, umode_t mode,if (err && err != -EOPNOTSUPP ) goto fail; + err =zuf_acls_create_pre (dir, inode, &acl); +if (unlikely (err)) + goto fail; +zuf_set_inode_flags (inode, &ioc_new_inode.zi); if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
@@ -406,6 +411,12 @@ struct inode *zuf_new_inode(struct inode *dir, umode_t mode,zuf_dbg_verbose ("allocating inode %ld (zi=%p)\n" ,_zi_ino (zi), zi); +if (acl && !symname) { + err =zuf_acls_create_post (dir, inode, acl); +if (unlikely (err)) + goto fail; + } + err =insert_inode_locked (inode);if (unlikely (err)) { zuf_dbg_err("[%ld:%s] generation=%lld insert_inode_locked => %d\n",
fs/zuf/namei.c +4 -0
@@ -420,6 +420,8 @@ const struct inode_operations zuf_dir_inode_operations = { .setattr = zuf_setattr, .getattr = zuf_getattr, .update_time = zuf_update_time, + .get_acl = zuf_get_acl, + .set_acl = zuf_set_acl, .listxattr = zuf_listxattr, };
@@ -427,5 +429,7 @@ const struct inode_operations zuf_special_inode_operations = { .setattr = zuf_setattr, .getattr = zuf_getattr, .update_time = zuf_update_time, + .get_acl = zuf_get_acl, + .set_acl = zuf_set_acl, .listxattr = zuf_listxattr, };
fs/zuf/zuf.h +6 -0
@@ -335,6 +335,12 @@ enum { ZUF_XF_SECURITY = 1, ZUF_XF_USER = 4, }; +struct zuf_acl { +__le16 tag; +__le16 perm; +__le32 id; +} __packed; +enum big_alloc_type { ba_stack, ba_kmalloc, ba_vmalloc }; static inline
Signature · 1 line
2.20.1
RFC PATCH 16/17 zuf: Special IOCTL fadvise (TODO)
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
We establish an fadvise dispatch with zus.
We also define a new IOCTL to drive this into zuf. The IOCTL has the same structure and constants as the fadvise syscall.
However:
TODO:
The VFS does not call into the FS for fadvise, And since we do not use a page-cache it is an no-op for zuf.
We need to send a patch to vfs that lets an FS Hop in if it wants to implement its own fadvise.
--- fs/zuf/_extern.h | 2 ++ fs/zuf/ioctl.c | 25 ++++++++++++++++++++++ fs/zuf/rw.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/zuf-core.c | 1 + fs/zuf/zus_api.h | 14 ++++++++++++ 5 files changed, 96 insertions(+)
fs/zuf/_extern.h +2 -0
@@ -66,6 +66,8 @@ ssize_t zuf_rw_read_iter(struct super_block *sb, struct inode *inode,ssize_t zuf_rw_write_iter (struct super_block *sb,struct inode *inode,struct kiocb *kiocb,struct iov_iter *ii);int zuf_trim_edge (struct inode *inode,ulong filepos,uint len); +int zuf_fadvise (struct super_block *sb,struct inode *inode, +loff_t offset,loff_t len,int advise,bool rand);int zuf_iom_execute_sync (struct super_block *sb,struct inode *inode,__u64 *iom_e,uint iom_n); int zuf_iom_execute_async(struct super_block *sb, struct zus_iomap_build *iomb,
fs/zuf/ioctl.c +25 -0
@@ -238,6 +238,29 @@ static int _ioc_setversion(struct inode *inode, uint __user *parg)return err; } +static int _ioc_fadvise (struct file *file,ulong arg) +{ +struct inode *inode =file_inode (file); +struct zuf_inode_info *zii =ZUII (inode); +struct zufs_ioc_fadvise iof = {}; +int err; + +if (!S_ISREG (inode->i_mode)) +return -EINVAL ; + +if (arg &©_from_user (&iof, (void __user *)arg,sizeof (iof))) +return -EFAULT ; + +zuf_r_lock (zii); + + err =zuf_fadvise (inode->i_sb, inode, iof.offset, iof.length, + iof.advise, file->f_mode &FMODE_RANDOM ); + +zuf_r_unlock (zii); + +return err; +} +long zuf_ioctl (struct file *filp,unsigned int cmd,ulong arg) {struct inode *inode = filp->f_inode;
@@ -252,6 +275,8 @@ long zuf_ioctl(struct file *filp, unsigned int cmd, ulong arg)return put_user (inode->i_generation, (int __user *)arg);case FS_IOC_SETVERSION :return _ioc_setversion (inode, parg); +case ZUFS_IOC_FADVISE : +return _ioc_fadvise (filp, arg);default :return _ioctl_dispatch (inode, cmd, arg); }
fs/zuf/rw.c +54 -0
60 lines not on this page · raw message
fs/zuf/zuf-core.c +1 -0
@@ -778,6 +778,7 @@ const char *zuf_op_name(enum e_zufs_operation op)CASE_ENUM_NAME (ZUFS_OP_CLONE );CASE_ENUM_NAME (ZUFS_OP_COPY );CASE_ENUM_NAME (ZUFS_OP_READ ); +CASE_ENUM_NAME (ZUFS_OP_PRE_READ );CASE_ENUM_NAME (ZUFS_OP_WRITE );CASE_ENUM_NAME (ZUFS_OP_GET_BLOCK );CASE_ENUM_NAME (ZUFS_OP_PUT_BLOCK );
fs/zuf/zus_api.h +14 -0
@@ -159,6 +159,19 @@ struct zus_inode {/* Total ZUFS_INODE_SIZE bytes always */ }; +/* ~~~~~ vfs extension ioctl commands ~~~~~ */ + +/* TODO: This one needs to be an FS vector called from +* the fadvise() system call. (Future patch) +*/ +struct zufs_ioc_fadvise { +__u64 offset; +__u64 length;/* if 0 all file */ +__u64 advise; +} __packed; + +#define ZUFS_IOC_FADVISE _IOW('S', 2, struct zufs_ioc_fadvise) +/* ~~~~~ ZUFS API ioctl commands ~~~~~ */ enum {ZUS_API_MAP_MAX_PAGES =1024 ,
@@ -341,6 +354,7 @@ enum e_zufs_operation {ZUFS_OP_COPY ,ZUFS_OP_READ , +ZUFS_OP_PRE_READ ,ZUFS_OP_WRITE ,ZUFS_OP_GET_BLOCK , ZUFS_OP_PUT_BLOCK,
Signature · 1 line
2.20.1
RFC PATCH 17/17 zuf: Support for dynamic-debug of zusFSs
In reply to Boaz harroshFrom: Boaz Harrosh <[email protected]>
In zus we support dynamic-debug prints. ie user can turn on and off the prints at run time by writing to some special files.
The API is exactly the same as the Kernel's dynamic-prints only the special file that we perform read/write on is:
/sys/fs/zuf/ddbg
But otherwise it is identical to Kernel.
The Kernel code is a thin wrapper to dispatch to/from the read/write of /sys/fs/zuf/ddbg file to the zus server.
The heavy lifting is done by the zus project build system and core code. See zus project how this is done
This facility is dispatched on the mount-thread and not the regular ZTs. Because it is available globally before any mounts.
--- fs/zuf/zuf-core.c | 1 + fs/zuf/zuf-root.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ fs/zuf/zus_api.h | 12 +++++++- 3 files changed, 89 insertions(+), 1 deletion(-)
fs/zuf/zuf-core.c +1 -0
@@ -777,6 +777,7 @@ const char *zuf_op_name(enum e_zufs_operation op)CASE_ENUM_NAME (ZUFS_OP_READDIR );CASE_ENUM_NAME (ZUFS_OP_CLONE );CASE_ENUM_NAME (ZUFS_OP_COPY ); +CASE_ENUM_NAME (ZUFS_OP_READ );CASE_ENUM_NAME (ZUFS_OP_PRE_READ );CASE_ENUM_NAME (ZUFS_OP_WRITE );
fs/zuf/zuf-root.c +77 -0
89 lines not on this page · raw message
fs/zuf/zus_api.h +11 -1
@@ -268,10 +268,20 @@ struct zufs_mount_info {struct zufs_parse_options po; }; +struct zufs_ddbg_info { +__u64 id;/* IN where to start from, OUT last ID */ +/* IN size of buffer, OUT size of dynamic debug message */ +__u64 len; +char msg[0 ]; +}; +/* mount / umount */ struct zufs_ioc_mount {struct zufs_ioc_hdr hdr; -struct zufs_mount_info zmi; +union { +struct zufs_mount_info zmi; +struct zufs_ddbg_info zdi; + }; };#define ZU_IOC_MOUNT _IOWR('Z', 11, struct zufs_ioc_mount)
Signature · 1 line
2.20.1
Quoted 4 lines · Boaz harrosh
Please see first patch for License of this project
Current status: There are a couple of trivial open-source filesystem implementations and a full blown proprietary implementation from Netapp.
I regard this patchset as being an attempt to avoid your obligations under the GPL. As such, I will not be reviewing this code and I oppose its inclusion.
Quoted 10 lines · Matthew Wilcox
Quoted 4 lines · Boaz harrosh
Please see first patch for License of this project
Current status: There are a couple of trivial open-source filesystem implementations and a full blown proprietary implementation from Netapp.
I regard this patchset as being an attempt to avoid your obligations under the GPL. As such, I will not be reviewing this code and I oppose its inclusion.
Dearest Matthew
One day We'll sit on a bear and you explain to me. I do trust your opinion, but I do not understand.
Specifically the above "full blown proprietary implementation from Netapp" does not break the GPL at all. Parts of it are written in languages alien to the Kernel and parts using user-mode libs and code IP that are not able to live in the Kernel. At the beginning we had code to inject the FS into the application of choice vi ld.so and only selected apps like a DB would have a view of the filesystem. But you can imagine how this is a nightmare for IT. Being POSIX under the Kernel is just so much less inventing the wheel
say: backup, disaster-recovery, cloud ....
Now actually if you look at the code submitted you will see that we are using very very little out of the Kernel. Actually for comparison FUSE is using the Kernel much heavier. Utilizing page-cache, Kernel re-claimers. Smart write-back the lot. In ZUFS we take the upper most interfaces and send it down stream as is. Where ever there is depth of stack we take the top most level and push that to server as is completely synchronous to the app threads.
The only real novelty in this project is something completely new to this submission, it is the new RPC we invented here that utilizes per-cpu Technics to show a kind of performance never seen before between two processes.
You are a Kernel contributor, you have IP in the Kernel. Your opinion is very important to me and to Netapp. Please point me to these areas that you feel I have stepped on your IP, and have not respected the GPL? And I would want very much to fix it.
Or maybe my sin is that I am to successful? Is the GPL guarded by speed? I mean say FUSE it is already doing all these sins. And or other subsystems that bridge Kernel functionality to user-mode. There are other user-mode "drivers" all over the place. But they are all so slooooooow. So a serious FS or server needs to sit in Kernel. With zufs we can now delegate to user-mode. The kernel becomes a micro-kernel, very-fast-bridge, and moves out of the way. Creating space for serious servers to sit in userland.
To summarize. I take your statement very seriously. Please state what service of the GPLed Kernel am I exposing and circumventing and I will want to fix it ASAP. I thought, and my philosophy was to take the POSIX interfaces as high as possible and shove them to userland. In an RPC manner that I invented that is very fast. If there are such areas that I am not doing so. Please show me?
Best regards
Boaz
Re: [RFC PATCH 02/17] zuf: Preliminary Documentation
In reply to Boaz harroshDocumentation/filesystems/zufs.txt line 227
Quoted 12 lines · Boaz harrosh
+4. An FS operation like create or WRITE/READ and so on arrives from application
Documentation/filesystems/zufs.txt new file +9
-0+ via VFS. Eventually an Operation is dispatched to zus: + ▪ A special per-operation descriptor is filled up with all parameters. + ▪ A current CPU channel is grabbed. the operation descriptor is put on + that channel (ZT). Including get_user_pages or Kernel-pages associated + with this OPT. + ▪ The ZT is awaken, app thread put to sleep. + ▪ In ZT context pages are mapped to that ZT-vma. This is so we are sure + the map is only on a single core. And no other core's TLB is affected. + (This here is the all performance secret)
I still don't get it. You say mapping the page to server address space is the performance secret. I say it's a security issue as well as being perfectly useless, except for special cases.
So let's see. There's the pmem case, which seems to be what this is
mostly about. So we take a pmem filesystem and e.g. a read(2)
syscall. There's no zero copy to talk about in that case since data
needs to be copied from pmem to application buffer. If we want to
minimize memory copies, than it will be a single memory copy from pmem
to the app buffer. Your implementation chooses to do this copy in
the userland server, via the application buffer mapped into its
address space. But the memory copy could just as well be done by the
kernel, from one virtual address to another; the kernel just has to juggle with physical page lookups, but does not have to establish a new mapping, which makes it all the more secure and performant.
Sure, we've heard about arguments why the above doesn't work if the data comes from e.g. a network where the network driver could be writing data directly to application buffer. But I've shown how that could also be done with a new rsplice() interface, again without having to insert the application page into the server address space. And no, this doesn't have to involve syscall overhead, if that turns out to be the limiting factor: mapped pipes might be an interesting new concept as well.
The only way I see this implementation actually save a memory copy is if a transformation is required (which again, already implies at least
a single memory copy) such as compression or encryption. But even
that could be delegated to the kernel, since it does have plenty of such transformations implemented, only an interface is required to tell the kernel which one to do on the buffer.
Thanks,
Miklos
Re: [RFC PATCH 01/17] fs: Add the ZUF filesystem to the build + License
In reply to Boaz harroshQuoted 5 lines · Boaz harrosh
However the ZUS user mode Server is a BSD-3-Clause licensed project.
Therefor you will see that:
zus_api.h
md_def.h
Quoted 8 lines
md.h
These are common files with ZUS project are separately Licensed as BSD-3-Clause. Any contributor to these files should note that his code for these files is submitted as BSD-3-Clause.
This is for the obvious reasons as these define the API between Kernel an user-mode Server. It is the opinion of this project authors, as is of Linus that a pure API header is not governed by ANY license. But to make it clear.
No, that is not true, the files do have a license. Please see the proper SPDX text that we use for kernel api .h files for what that is, and what you should also use for yours, if you go through with this.
thanks,
greg k-h
Re: [RFC PATCH 09/17] zuf: symlink
In reply to Boaz harroshQuoted 3 lines · Boaz harrosh
From: Boaz Harrosh <[email protected]>
Signed-off-by Boaz Harrosh <[email protected]>
I know I never accept patches without any changelog text...
Re: [RFC PATCH 09/17] zuf: symlink
Quoted 7 lines · Greg KH
Quoted 3 lines · Boaz harrosh
From: Boaz Harrosh <[email protected]>
Signed-off-by Boaz Harrosh <[email protected]>I know I never accept patches without any changelog text...
Ooops sorry, totally right. Me too ;-)
Will fix ASAP
Thanks
Boaz
Re: [RFC PATCH 02/17] zuf: Preliminary Documentation
In reply to Miklos SzerediQuoted 14 lines · Miklos Szeredi
Documentation/filesystems/zufs.txt line 227
Quoted 12 lines · Boaz harrosh
+4. An FS operation like create or WRITE/READ and so on arrives from application
Documentation/filesystems/zufs.txt new file +9
-0+ via VFS. Eventually an Operation is dispatched to zus: + ▪ A special per-operation descriptor is filled up with all parameters. + ▪ A current CPU channel is grabbed. the operation descriptor is put on + that channel (ZT). Including get_user_pages or Kernel-pages associated + with this OPT. + ▪ The ZT is awaken, app thread put to sleep. + ▪ In ZT context pages are mapped to that ZT-vma. This is so we are sure + the map is only on a single core. And no other core's TLB is affected. + (This here is the all performance secret)
Quoted 4 lines
I still don't get it. You say mapping the page to server address space is the performance secret. I say it's a security issue as well as being perfectly useless, except for special cases.
Already working on this. Will submit new code in a month. There is already an API of GET_BLOCK that returns one or more server blocks (vi dpp_t) to Kernel. Today it is used in mmap, to directly map pmem to application space. We will use this API to memcpy(nt) in kernel space.
The mapping facility will be optional for zusFS(s) but the preferred way will be Kernel side copy.
This is because vm_zap_ptes() is way way to slow in current design and I need things faster ...
<>
Quoted 3 lines
Thanks,
Miklos
Thanks
Boaz
Re: [RFC PATCH 01/17] fs: Add the ZUF filesystem to the build + License
In reply to Greg KHQuoted 15 lines · Greg KH
Quoted 5 lines · Boaz harrosh
However the ZUS user mode Server is a BSD-3-Clause licensed project.
Therefor you will see that:
zus_api.h
md_def.hQuoted 8 lines
md.h
These are common files with ZUS project are separately Licensed as BSD-3-Clause. Any contributor to these files should note that his code for these files is submitted as BSD-3-Clause.
This is for the obvious reasons as these define the API between Kernel an user-mode Server. It is the opinion of this project authors, as is of Linus that a pure API header is not governed by ANY license. But to make it clear.
Quoted 4 lines
No, that is not true, the files do have a license. Please see the proper SPDX text that we use for kernel api .h files for what that is, and what you should also use for yours, if you go through with this.
OK Good I understand more now. I looked at UAPI/ headers and read the docs you mentioned.
Please help me nail this properly. I will change these headers to be:
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note AND BSD-3-Clause */ (I will also change the message text to reflect this conversation)
My motivation is that those Interface HEADERS can also be used in proprietary OSs as Macosx and Windows. To compile the ZUS Server application project which is licensed as SPDX BSD-3-Clause.
So I changed the OR to an AND right? Is it now clear that anyone adding new API interface like new operations. Understand that this applies also to BSD-3-Clause projects?
Quoted 2 lines
thanks,
greg k-h
Thanks very much for looking
Boaz
Re: [RFC PATCH 01/17] fs: Add the ZUF filesystem to the build + License
Quoted 24 lines · Boaz Harrosh
Quoted 15 lines · Greg KH
Quoted 5 lines · Boaz harrosh
However the ZUS user mode Server is a BSD-3-Clause licensed project.
Therefor you will see that:
zus_api.h
md_def.hQuoted 8 lines
md.h
These are common files with ZUS project are separately Licensed as BSD-3-Clause. Any contributor to these files should note that his code for these files is submitted as BSD-3-Clause.
This is for the obvious reasons as these define the API between Kernel an user-mode Server. It is the opinion of this project authors, as is of Linus that a pure API header is not governed by ANY license. But to make it clear.Quoted 4 lines
No, that is not true, the files do have a license. Please see the proper SPDX text that we use for kernel api .h files for what that is, and what you should also use for yours, if you go through with this.
OK Good I understand more now. I looked at UAPI/ headers and read the docs you mentioned.
Quoted 8 lines
Please help me nail this properly. I will change these headers to be:
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note AND BSD-3-Clause */ (I will also change the message text to reflect this conversation)
My motivation is that those Interface HEADERS can also be used in proprietary OSs as Macosx and Windows. To compile the ZUS Server application project which is licensed as SPDX BSD-3-Clause.
You are asking legal questions to a technical person? Would you ask medical questions to a lawyer?
Consult your lawyers please, they know the answers to this.
And if they do not, go find your corporate lawyers who do.
Hint, as a test, ask them why what you wrote as a suggested SPDX line above makes no sense :)
good luck!
greg k-h
Re: [RFC PATCH 01/17] fs: Add the ZUF filesystem to the build + License
In reply to Boaz harroshQuoted 85 lines · Boaz harrosh
NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.
From: Boaz Harrosh <[email protected]>
This adds the ZUF filesystem-in-user_mode module to the
fs/build system.Also added:
*fs/zuf/Kconfig
*fs/zuf/module.c- This file contains the LICENCE of zuf code base
*fs/zuf/Makefile- Rather emptyMakefilewith onlymodule.caboveI add the
fs/zuf/Makefileto demonstrate that at every patchset stage code still compiles and there are no external references outside of the code already submitted.Off course only at the very last patch we have a working ZUF feeder
[LICENCE]
zuf.ko is a GPLv2 licensed project.
However the ZUS user mode Server is a BSD-3-Clause licensed project.
Therefor you will see that:
zus_api.h
md_def.h
md.h
These are common files with ZUS project are separately Licensed as BSD-3-Clause. Any contributor to these files should note that his code for these files is submitted as BSD-3-Clause.
This is for the obvious reasons as these define the API between Kernel an user-mode Server. It is the opinion of this project authors, as is of Linus that a pure API header is not governed by ANY license. But to make it clear.Signed-off-by Boaz Harrosh <[email protected]>--- fs/Kconfig | 1 + fs/Makefile | 1 + fs/zuf/Kconfig | 28 ++++++++++++++++++++ fs/zuf/Makefile | 14 ++++++++++ fs/zuf/module.c | 28 ++++++++++++++++++++ fs/zuf/zus_api.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 141 insertions(+) create mode 100644 fs/zuf/Kconfig create mode 100644 fs/zuf/Makefile create mode 100644 fs/zuf/module.c create mode 100644 fs/zuf/zus_api.hfs/Kconfig +1
-0@@ -254,6 +254,7 @@ source "fs/romfs/Kconfig" source "fs/pstore/Kconfig" source "fs/sysv/Kconfig" source "fs/ufs/Kconfig" +source "fs/zuf/Kconfig" source "fs/exofs/Kconfig" endif # MISC_FILESYSTEMSfs/Makefile +0
-0@@ -128,3 +128,4 @@ obj-y += exofs/ # Multiplemodules
obj-$(CONFIG_CEPH_FS) += ceph/
obj-$(CONFIG_PSTORE) += pstore/
obj-$(CONFIG_EFIVAR_FS) += efivarfs/fs/Makefile +1
-0+obj-$(CONFIG_ZUF) += zuf/fs/zuf/Kconfig new file +0
-0
fs/zuf/Kconfig line 1
Quoted 1 line
fs/zuf/Kconfig new file +1
-0@@ -0,0 +1,28 @@ +menuconfig ZUF
Shouldn't this be "CONFIG_ZUF_FS" to stay consistent with other filesystems?
Quoted 159 lines
fs/zuf/Kconfig new file +27
-0+ tristate "ZUF - Zero-copy User-mode Feeder" + depends on BLOCK + depends on ZONE_DEVICE + select CRC16 + select MEMCG + help + ZUFS Kernel part. + To enable say Y here. + + To compile this as a module, choose M here: the module will be + called zuf.ko + +if ZUF + +config ZUF_DEBUG + bool "ZUF: enable debug subsystems use" + depends on ZUF + default n + help + INTERNAL QA USE ONLY!!! DO NOT USE!!! + Please leave as N here + + This option adds some extra code that helps + in QA testing of the code. It may slow the + operation and produce bigger code + +endiffs/zuf/Makefile new file +14
-0@@ -0,0 +1,14 @@ +# +# ZUF: Zero-copy User-mode Feeder +# +# Copyright (c) 2018 NetApp Inc. All rights reserved. +# +# ZUFS-License: GPL-2.0. See module.c for LICENSE details. +# +# Makefile for the Linux zufs Kernel Feeder. +# + +obj-$(CONFIG_ZUF) += zuf.o + +# Main FS +zuf-y += module.ofs/zuf/module.c new file +28
-0@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* zuf - Zero-copy User-mode Feeder +* +* Copyright (c) 2018 NetApp Inc. All rights reserved. +* +* This program is free software; you may redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 2 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <https://www.gnu.org/licenses/>;. +*/ +#include <linux/module.h> + +#include "zus_api.h" + +MODULE_AUTHOR ("Boaz Harrosh <[email protected]>" ); +MODULE_AUTHOR ("Sagi Manole <[email protected]>" ); +MODULE_DESCRIPTION ("Zero-copy User-mode Feeder" ); +MODULE_LICENSE ("GPL" ); +MODULE_VERSION(__stringify(ZUFS_MAJOR_VERSION) "." + __stringify(ZUFS_MINOR_VERSION));fs/zuf/zus_api.h new file +69
-1@@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */ +/* +* zufs_api.h: +* ZUFS (Zero-copy User-mode File System) is: +* zuf (Zero-copy User-mode Feeder (Kernel)) + +* zus (Zero-copy User-mode Server (daemon)) +* +* Copyright (c) 2018 NetApp Inc. All rights reserved. +* +* Authors: +* Boaz Harrosh <[email protected]> +* Sagi Manole <[email protected]>" +*/ +#ifndef _LINUX_ZUFS_API_H +#define _LINUX_ZUFS_API_H + +#include <linux/types.h> +#include <linux/uuid.h> +#include <stddef.h> +#include <linux/statfs.h> + +/* +* Version rules: +* This is the zus-to-zuf API version. And not the Filesystem +* on disk structures versions. These are left to the FS-plugging +* to supply and check. +* Specifically any of the API structures and constants found in this +* file. +* If the changes are made in a way backward compatible with old +* user-space, MINOR is incremented. Else MAJOR is incremented. +* +* We believe that the zus Server application comes with the +* Distro and should be dependent on the Kernel package. +* (In rhel they are both in the same package) +* +* The more stable ABI is between the zus Server and its FS plugins. +*/ +#define ZUFS_MINORS_PER_MAJOR 1024 +#define ZUFS_MAJOR_VERSION 1 +#define ZUFS_MINOR_VERSION 0 + +/* User space compatibility definitions */ +#ifndef __KERNEL__ + +#include <string.h> + +#define u8 uint8_t +#define umode_t uint16_t + +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) + +#ifndef __packed +# define __packed __attribute__((packed)) +#endif + +#ifndef ALIGN +#define ALIGN (x, a) ALIGN_MASK(x, (typeof(x))(a) - 1) +#define ALIGN_MASK (x, mask) (((x) + (mask)) & ~(mask)) +#endif + +/* RHEL/CentOS7 specifics */ +#ifndef FALLOC_FL_UNSHARE_RANGE +#define FALLOC_FL_UNSHARE_RANGE 0x40 +#endif + +#endif /* ndef __KERNEL__ */ + +#endif /* _LINUX_ZUFS_API_H */ --2.20.1
Re: [RFC PATCH 04/17] zuf: zuf-core The ZTs
In reply to Boaz harroshQuoted 136 lines · Boaz harrosh
NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.
From: Boaz Harrosh <[email protected]>
zuf-core established the communication channels with the ZUS User Mode Server.
In this patch we have the core communication mechanics. Which is the Novelty of this project.
(See previous submitted documentation for more info)Users will come later in the patchset
Signed-off-by Boaz Harrosh <[email protected]>--- fs/zuf/_extern.h | 22 + fs/zuf/_pr.h | 4 + fs/zuf/relay.h | 88 ++++ fs/zuf/zuf-core.c | 1016 ++++++++++++++++++++++++++++++++++++++++++++- fs/zuf/zuf-root.c | 7 + fs/zuf/zuf.h | 46 ++ fs/zuf/zus_api.h | 185 +++++++++ 7 files changed, 1367 insertions(+), 1 deletion(-) create mode 100644 fs/zuf/relay.hfs/zuf/_extern.h +22
-0@@ -28,10 +28,32 @@ struct dentry *zuf_mount(struct file_system_type *fs_type,int flags, const char *dev_name, void *data);/* zuf-core.c */ +int zufc_zts_init (struct zuf_root_info *zri);/* Some private types in core */ +void zufc_zts_fini (struct zuf_root_info *zri); +long zufc_ioctl (struct file *filp,unsigned int cmd,ulong arg);int zufc_release (struct inode *inode,struct file *file);int zufc_mmap (struct file *file,struct vm_area_struct *vma); +int __zufc_dispatch_mount (struct zuf_root_info *zri, +enum e_mount_operation op, +struct zufs_ioc_mount *zim); +int zufc_dispatch_mount (struct zuf_root_info *zri,struct zus_fs_info *zus_zfi, +enum e_mount_operation operation, +struct zufs_ioc_mount *zim); + +const char *zuf_op_name (enum e_zufs_operation op); +int __zufc_dispatch (struct zuf_root_info *zri,struct zuf_dispatch_op *zdo); +static inline +int zufc_dispatch (struct zuf_root_info *zri,struct zufs_ioc_hdr *hdr, +struct page **pages,uint nump) +{ +struct zuf_dispatch_op zdo; + +zuf_dispatch_init (&zdo, hdr, pages, nump); +return __zufc_dispatch (zri, &zdo); +} +/*
zuf-root.c*/
int zufr_register_fs(structsuper_block*sb, structzufs_ioc_register_fs
*rfs);fs/zuf/_pr.h +4
-0@@ -39,5 +39,9 @@/* ~~~ channel prints ~~~ */ #define zuf_dbg_err(s, args ...) zuf_chan_debug("error", s, ##args) +#define zuf_dbg_vfs(s, args ...) zuf_chan_debug("vfs ", s, ##args) +#define zuf_dbg_core(s, args ...) zuf_chan_debug("core ", s, ##args) +#define zuf_dbg_zus(s, args ...) zuf_chan_debug("zusdg", s, ##args) +#define zuf_dbg_verbose(s, args ...) zuf_chan_debug("d-oto", s, ##args)#endif /* define __ZUF_PR_H__ */ fs/zuf/relay.h new file +46
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Relay scheduler-object Header file. +* +* Copyright (c) 2018 NetApp Inc. All rights reserved. +* +* ZUFS-License: GPL-2.0. See module.c for LICENSE details. +* +* Authors: +* Boaz Harrosh <[email protected]> +*/ + +#ifndef __RELAY_H__ +#define __RELAY_H__ + +/* ~~~~ Relay ~~~~ */ +struct relay { +wait_queue_head_t fss_wq; +bool fss_wakeup; +bool fss_waiting; + +wait_queue_head_t app_wq; +bool app_wakeup; +bool app_waiting; + +cpumask_t cpus_allowed; +}; + +static inline void relay_init (struct relay *relay) +{ +init_waitqueue_head (&relay->fss_wq); +init_waitqueue_head (&relay->app_wq); +} + +static inline bool relay_is_app_waiting (struct relay *relay) +{ +return relay->app_waiting; +} + +static inline void relay_app_wakeup (struct relay *relay) +{ + relay->app_waiting = false; + + relay->app_wakeup = true; +wake_up (&relay->app_wq); +}
fs/zuf/relay.h line 56
Quoted 10 lines
fs/zuf/relay.h new file +10
-0+ +static inline int relay_fss_wait (struct relay *relay) +{ +int err; + + relay->fss_waiting = true; + relay->fss_wakeup = false; + err =wait_event_interruptible (relay->fss_wq, relay->fss_wakeup); + +return err;
Could you just do: "return wait_event_interruptible()" directly, instead of using the err variable?
Quoted 126 lines
fs/zuf/relay.h new file +32
-0+} + +static inline bool relay_is_fss_waiting_grab (struct relay *relay) +{ +if (relay->fss_waiting) { + relay->fss_waiting = false; +return true; + } +return false; +} + +static inline void relay_fss_wakeup (struct relay *relay) +{ + relay->fss_wakeup = true; +wake_up (&relay->fss_wq); +} + +static inline void relay_fss_wakeup_app_wait (struct relay *relay, +spinlock_t *spinlock) +{ + relay->app_waiting = true; + +relay_fss_wakeup (relay); + + relay->app_wakeup = false; +if (spinlock) +spin_unlock (spinlock); + +wait_event (relay->app_wq, relay->app_wakeup); +} + +#endif /* ifndef __RELAY_H__ */ fs/zuf/zuf-core.c +82
-0@@ -18,14 +18,820 @@#include <linux/delay.h> #include <linux/pfn_t.h> #include <linux/sched/signal.h> +#include <linux/uaccess.h> #include "zuf.h" +struct zufc_thread { +struct zuf_special_file hdr; +struct relay relay; +struct vm_area_struct *vma; +int no; +int chan; + +/* Kernel side allocated IOCTL buffer */ +struct vm_area_struct *opt_buff_vma; +void *opt_buff; +ulong max_zt_command; + +/* Next operation*/ +struct zuf_dispatch_op *zdo; +}; + +enum {INITIAL_ZT_CHANNELS =3 }; + +struct zuf_threads_pool { +uint _max_zts; +uint _max_channels; +/* array of pcp_arrays */ +struct zufc_thread *_all_zt[ZUFS_MAX_ZT_CHANNELS ]; +}; + +static int _alloc_zts_channel (struct zuf_root_info *zri,int channel) +{ + zri->_ztp->_all_zt[channel] = alloc_percpu(struct zufc_thread); +if (unlikely (!zri->_ztp->_all_zt[channel])) { +zuf_err ("!!! alloc_percpu channel=%d failed\n" , channel); +return -ENOMEM ; + } +return 0 ; +} + +static inline ulong _zt_pr_no (struct zufc_thread *zt) +{ +/* So in hex it will be channel as first nibble and cpu as 3rd and on */ +return ((ulong )zt->no <<8 ) | zt->chan; +} + +int zufc_zts_init (struct zuf_root_info *zri) +{ +int c; + + zri->_ztp =kcalloc (1 ,sizeof (struct zuf_threads_pool ),GFP_KERNEL ); +if (unlikely (!zri->_ztp)) +return -ENOMEM ; + + zri->_ztp->_max_zts =num_online_cpus (); + zri->_ztp->_max_channels =INITIAL_ZT_CHANNELS ; + +for (c =0 ; c <INITIAL_ZT_CHANNELS ; ++c) { +int err =_alloc_zts_channel (zri, c); + +if (unlikely (err)) +return err; + } + +return 0 ; +} + +void zufc_zts_fini (struct zuf_root_info *zri) +{ +int c; + +/* Always safe/must call zufc_zts_fini */ +if (!zri->_ztp) +return ; + +for (c =0 ; c < zri->_ztp->_max_channels; ++c) { +if (zri->_ztp->_all_zt[c]) +free_percpu (zri->_ztp->_all_zt[c]); + } +kfree (zri->_ztp); + zri->_ztp =NULL ; +} + +static struct zufc_thread *_zt_from_cpu (struct zuf_root_info *zri, +int cpu,uint chan) +{
fs/zuf/zuf-core.c line 116
Quoted 10 lines
fs/zuf/zuf-core.c +10
-0+return per_cpu_ptr (zri->_ztp->_all_zt[chan], cpu); +} + +static int _zt_from_f (struct file *filp,int cpu,uint chan, +struct zufc_thread **ztp) +{ + *ztp =_zt_from_cpu (ZRI (filp->f_inode->i_sb), cpu, chan); +if (unlikely (!*ztp)) +return -ERANGE ; +return 0 ;
I'm curious if there is a reason you did it this way instead of making use of the ERR_PTR() macro to return ztp directly?
Quoted 1,277 lines
fs/zuf/zuf-core.c +527
-0+} + +static int _zu_register_fs (struct file *file,void *parg) +{ +struct zufs_ioc_register_fs rfs; +int err; + + err =copy_from_user (&rfs, parg,sizeof (rfs)); +if (unlikely (err)) { +zuf_err ("=>%d\n" , err); +return err; + } + + err =zufr_register_fs (file->f_inode->i_sb, &rfs); +if (err) +zuf_err ("=>%d\n" , err); + err =put_user (err, (int *)parg); +return err; +} + +/* ~~~~ mounting ~~~~*/ +int __zufc_dispatch_mount (struct zuf_root_info *zri, +enum e_mount_operation operation, +struct zufs_ioc_mount *zim) +{ + zim->hdr.operation = operation; + +for (;;) { +bool fss_waiting; + +spin_lock (&zri->mount.lock); + +if (unlikely (!zri->mount.zsf.file)) { +spin_unlock (&zri->mount.lock); +zuf_err ("Server not up\n" ); + zim->hdr.err = -EIO ; +return zim->hdr.err; + } + + fss_waiting =relay_is_fss_waiting_grab (&zri->mount.relay); +if (fss_waiting) +break ; +/* in case of break above spin_unlock is done inside +* relay_fss_wakeup_app_wait +*/ + +spin_unlock (&zri->mount.lock); + +/* It is OK to wait if user storms mounts */ +zuf_dbg_verbose ("waiting\n" ); +msleep (100 ); + } + + zri->mount.zim = zim; +relay_fss_wakeup_app_wait (&zri->mount.relay, &zri->mount.lock); + +return zim->hdr.err; +} + +int zufc_dispatch_mount (struct zuf_root_info *zri,struct zus_fs_info *zus_zfi, +enum e_mount_operation operation, +struct zufs_ioc_mount *zim) +{ + zim->hdr.out_len =sizeof (*zim); + zim->hdr.in_len =sizeof (*zim); +if (operation ==ZUFS_M_MOUNT || operation ==ZUFS_M_REMOUNT ) + zim->hdr.in_len += zim->zmi.po.mount_options_len; + zim->zmi.zus_zfi = zus_zfi; + zim->zmi.num_cpu = zri->_ztp->_max_zts; + zim->zmi.num_channels = zri->_ztp->_max_channels; + +return __zufc_dispatch_mount (zri, operation, zim); +} + +static int _zu_mount (struct file *file,void *parg) +{ +struct super_block *sb = file->f_inode->i_sb; +struct zuf_root_info *zri =ZRI (sb); +bool waiting_for_reply; +struct zufs_ioc_mount *zim; +ulong cp_ret; +int err; + +spin_lock (&zri->mount.lock); + +if (unlikely (!file->private_data)) { +/* First time register this file as the mount-thread owner */ + zri->mount.zsf.type = zlfs_e_mout_thread; + zri->mount.zsf.file = file; + file->private_data = &zri->mount.zsf; + }else if (unlikely (file->private_data != &zri->mount)) { +spin_unlock (&zri->mount.lock); +zuf_err ("Say what?? %p != %p\n" , + file->private_data, &zri->mount); +return -EIO ; + } + + zim = zri->mount.zim; + zri->mount.zim =NULL ; + waiting_for_reply = zim &&relay_is_app_waiting (&zri->mount.relay); + +spin_unlock (&zri->mount.lock); + +if (waiting_for_reply) { + cp_ret =copy_from_user (zim, parg, zim->hdr.out_len); +if (unlikely (cp_ret)) { +zuf_err ("copy_from_user => %ld\n" , cp_ret); + zim->hdr.err = -EFAULT ; + } + +relay_app_wakeup (&zri->mount.relay); + } + +/* This gets to sleep until a mount comes */ + err =relay_fss_wait (&zri->mount.relay); +if (unlikely (err || !zri->mount.zim)) { +struct zufs_ioc_hdr *hdr = parg; + +/* Released by _zu_break INTER or crash */ +zuf_dbg_zus ("_zu_break? %p => %d\n" , zri->mount.zim, err); +put_user (ZUFS_OP_BREAK , &hdr->operation); +put_user (EIO , &hdr->err); +return err; + } + + zim = zri->mount.zim; + cp_ret =copy_to_user (parg, zim, zim->hdr.in_len); +if (unlikely (cp_ret)) { + err = -EFAULT ; +zuf_err ("copy_to_user =>%ld\n" , cp_ret); + } +return err; +} + +static void zufc_mounter_release (struct file *file) +{ +struct zuf_root_info *zri =ZRI (file->f_inode->i_sb); + +zuf_dbg_zus ("closed fu=%d au=%d fw=%d aw=%d\n" , + zri->mount.relay.fss_wakeup, zri->mount.relay.app_wakeup, + zri->mount.relay.fss_waiting, zri->mount.relay.app_waiting); + +spin_lock (&zri->mount.lock); + zri->mount.zsf.file =NULL ; +if (relay_is_app_waiting (&zri->mount.relay)) { +zuf_err ("server emergency exit while IO\n" ); + +if (zri->mount.zim) + zri->mount.zim->hdr.err = -EIO ; +spin_unlock (&zri->mount.lock); + +relay_app_wakeup (&zri->mount.relay); +msleep (1000 );/* crap */ + }else { +if (zri->mount.zim) + zri->mount.zim->hdr.err =0 ; +spin_unlock (&zri->mount.lock); + } +} + +/* ~~~~ ZU_IOC_NUMA_MAP ~~~~ */ +static int _zu_numa_map (struct file *file,void *parg) +{ +struct zufs_ioc_numa_map *numa_map; +int n_nodes =num_online_nodes (); +int n_cpus =num_online_cpus (); +uint *nodes_cpu_count; +uint max_cpu_per_node =0 ; +uint alloc_size; +int cpu, i, err; + + alloc_size =sizeof (*numa_map) + n_cpus;/* char per cpu */ + +if ((n_nodes >255 ) || (alloc_size >PAGE_SIZE )) { + zuf_warn("!!!unexpected big machine with %d nodes alloc_size=0x%x\n", + n_nodes, alloc_size); +return -ENOTSUPP ; + } + + nodes_cpu_count =kcalloc (n_nodes,sizeof (uint),GFP_KERNEL ); +if (unlikely (!nodes_cpu_count)) +return -ENOMEM ; + + numa_map =kzalloc (alloc_size,GFP_KERNEL ); +if (unlikely (!numa_map)) { + err = -ENOMEM ; + goto out; + } + + numa_map->possible_nodes =num_possible_nodes (); + numa_map->possible_cpus =num_possible_cpus (); + + numa_map->online_nodes = n_nodes; + numa_map->online_cpus = n_cpus; + +for_each_cpu (cpu, cpu_online_mask) { +uint ctn =cpu_to_node (cpu); +uint ncc = ++nodes_cpu_count[ctn]; + + numa_map->cpu_to_node[cpu] = ctn; + max_cpu_per_node =max (max_cpu_per_node, ncc); + } + +for (i =1 ; i < n_nodes; ++i) { +if (nodes_cpu_count[i] != nodes_cpu_count[0 ]) { +zuf_info ("@[%d]=%d Unbalanced CPU sockets @[0]=%d\n" , + i, nodes_cpu_count[i], nodes_cpu_count[0 ]); + numa_map->nodes_not_symmetrical = true; +break ; + } + } + + numa_map->max_cpu_per_node = max_cpu_per_node; + +zuf_dbg_verbose ( +"possible_nodes=%d possible_cpus=%d online_nodes=%d online_cpus=%d\n", + numa_map->possible_nodes, numa_map->possible_cpus, + n_nodes, n_cpus); + + err =copy_to_user (parg, numa_map, alloc_size); +kfree (numa_map); +out: +kfree (nodes_cpu_count); +return err; +} + +static int _map_pages (struct zufc_thread *zt,struct page **pages,uint nump, +bool map_readonly) +{ +int p, err; + +if (!(zt->vma && pages && nump)) +return 0 ; + +for (p =0 ; p < nump; ++p) { +ulong zt_addr = zt->vma->vm_start + p *PAGE_SIZE ; +ulong pfn =page_to_pfn (pages[p]); +pfn_t pfnt =phys_to_pfn_t (PFN_PHYS (pfn),PFN_MAP |PFN_DEV ); +vm_fault_t flt; + +if (map_readonly) + flt =vmf_insert_mixed (zt->vma, zt_addr, pfnt); +else + flt =vmf_insert_mixed_mkwrite (zt->vma, zt_addr, pfnt); + err =zuf_flt_to_err (flt); +if (unlikely (err)) { + zuf_err("zuf: remap_pfn_range => %d p=0x%x start=0x%lx\n", + err, p, zt->vma->vm_start); +return err; + } + } +return 0 ; +} + +static void _unmap_pages (struct zufc_thread *zt,struct page **pages,uint nump) +{ +if (!(zt->vma && zt->zdo && pages && nump)) +return ; + + zt->zdo->pages =NULL ; + zt->zdo->nump =0 ; + +zap_vma_ptes (zt->vma, zt->vma->vm_start, nump *PAGE_SIZE ); +} + +static void _fill_buff (ulong *buff,uint size) +{ +ulong *buff_end = buff + size; +ulong val =0 ; + +for (; buff < buff_end; ++buff, ++val) + *buff = val; +} + +static int _zu_init (struct file *file,void *parg) +{ +struct zufc_thread *zt; +int cpu =smp_processor_id (); +struct zufs_ioc_init zi_init; +int err; + + err =copy_from_user (&zi_init, parg,sizeof (zi_init)); +if (unlikely (err)) { +zuf_err ("=>%d\n" , err); +return err; + } +if (unlikely (zi_init.channel_no >=ZUFS_MAX_ZT_CHANNELS )) { +zuf_err ("[%d] channel_no=%d\n" , cpu, zi_init.channel_no); +return -EINVAL ; + } + +zuf_dbg_zus ("[%d] aff=0x%lx channel=%d\n" , + cpu, zi_init.affinity, zi_init.channel_no); + + zi_init.hdr.err =_zt_from_f (file, cpu, zi_init.channel_no, &zt); +if (unlikely (zi_init.hdr.err)) { +zuf_err ("=>%d\n" , err); + goto out; + } + +if (unlikely (zt->hdr.file)) { + zi_init.hdr.err = -EINVAL ; +zuf_err ("[%d] !!! thread already set\n" , cpu); + goto out; + } + +relay_init (&zt->relay); + zt->hdr.type = zlfs_e_zt; + zt->hdr.file = file; + zt->no = cpu; + zt->chan = zi_init.channel_no; + + zt->max_zt_command = zi_init.max_command; + zt->opt_buff =vmalloc (zi_init.max_command); +if (unlikely (!zt->opt_buff)) { + zi_init.hdr.err = -ENOMEM ; + goto out; + } +_fill_buff (zt->opt_buff, zi_init.max_command /sizeof (ulong)); + + file->private_data = &zt->hdr; +out: + err =copy_to_user (parg, &zi_init,sizeof (zi_init)); +if (err) +zuf_err ("=>%d\n" , err); +return err; +} + +struct zufc_thread *_zt_from_f_private (struct file *file) +{ +struct zuf_special_file *zsf = file->private_data; + +WARN_ON (zsf->type != zlfs_e_zt); + return container_of(zsf, struct zufc_thread, hdr); +} + +/* Caller checks that file->private_data != NULL */ +static void zufc_zt_release (struct file *file) +{ +struct zufc_thread *zt =_zt_from_f_private (file); + +if (unlikely (zt->hdr.file != file)) +zuf_err ("What happened zt->file(%p) != file(%p)\n" , + zt->hdr.file, file); + +zuf_dbg_zus ("[%d] closed fu=%d au=%d fw=%d aw=%d\n" , + zt->no, zt->relay.fss_wakeup, zt->relay.app_wakeup, + zt->relay.fss_waiting, zt->relay.app_waiting); + +if (relay_is_app_waiting (&zt->relay)) { +zuf_err ("server emergency exit while IO\n" ); + +/* NOTE: Do not call _unmap_pages the vma is gone */ + zt->hdr.file =NULL ; + +relay_app_wakeup (&zt->relay); +msleep (1000 );/* crap */ + } + +vfree (zt->opt_buff); +memset (zt,0 ,sizeof (*zt)); +} + +static int _copy_outputs (struct zufc_thread *zt,void *arg) +{ +struct zufs_ioc_hdr *hdr = zt->zdo->hdr; +struct zufs_ioc_hdr *user_hdr = zt->opt_buff; + +if (zt->opt_buff_vma->vm_start != (ulong )arg) { +zuf_err ("malicious Server\n" ); +return -EINVAL ; + } + +/* Update on the user out_len and return-code */ + hdr->err = user_hdr->err; + hdr->out_len = user_hdr->out_len; + +if (!hdr->out_len) +return 0 ; + +if ((hdr->err == -EZUFS_RETRY ) || (hdr->out_max < hdr->out_len)) { +if (WARN_ON (!zt->zdo->oh)) { +zuf_err ("Trouble op(%s) out_max=%d out_len=%d\n" , +zuf_op_name (hdr->operation), + hdr->out_max, hdr->out_len); +return -EFAULT ; + } +zuf_dbg_zus ("[%s] %d %d => %d\n" , +zuf_op_name (hdr->operation), + hdr->out_max, hdr->out_len, hdr->err); +return zt->zdo->oh (zt->zdo, zt->opt_buff, zt->max_zt_command); + }else { +void *rply = (void *)hdr + hdr->out_start; +void *from = zt->opt_buff + hdr->out_start; + +memcpy (rply, from, hdr->out_len); +return 0 ; + } +} + +static int _zu_wait (struct file *file,void *parg) +{ +struct zufc_thread *zt; +int err; + + zt =_zt_from_f_private (file); +if (unlikely (!zt)) { +zuf_err ("Unexpected ZT state\n" ); + err = -ERANGE ; + goto err; + } + +if (!zt->hdr.file || file != zt->hdr.file) { +zuf_err ("fatal\n" ); + err = -E2BIG ; + goto err; + } +if (unlikely ((ulong )parg != zt->opt_buff_vma->vm_start)) { +zuf_err ("fatal 2\n" ); + err = -EINVAL ; + goto err; + } + +if (relay_is_app_waiting (&zt->relay)) { +if (unlikely (!zt->zdo)) { +zuf_err ("User has gone...\n" ); + err = -E2BIG ; + goto err; + }else { +/* overflow_handler might decide to execute the +*parg here at zus context and return to server +* If it also has an error to report to zus it +* will set zdo->hdr->err. +* EZUS_RETRY_DONE is when that happens. +* In this case pages stay mapped in zt->vma +*/ + err =_copy_outputs (zt, parg); +if (err ==EZUF_RETRY_DONE ) { +put_user (zt->zdo->hdr->err, (int *)parg); +return 0 ; + } + +_unmap_pages (zt, zt->zdo->pages, zt->zdo->nump); + zt->zdo =NULL ; +if (unlikely (err))/* _copy_outputs returned an err */ + goto err; + } +relay_app_wakeup (&zt->relay); + } + + err =relay_fss_wait (&zt->relay); +if (err) +zuf_dbg_err ("[%d] relay error: %d\n" , zt->no, err); + +if (zt->zdo && zt->zdo->hdr && + zt->zdo->hdr->operation <ZUFS_OP_BREAK ) { +/* call map here at the zuf thread so we need no locks +* TODO: Currently only ZUFS_OP_WRITE protects user-buffers +* we should have a bit set in zt->zdo->hdr set per operation. +* TODO: Why this does not work? +*/ +_map_pages (zt, zt->zdo->pages, zt->zdo->nump,0 ); +memcpy (zt->opt_buff, zt->zdo->hdr, zt->zdo->hdr->in_len); + }else { +struct zufs_ioc_hdr *hdr = zt->opt_buff; + +/* This Means we were released by _zu_break */ +zuf_dbg_zus ("_zu_break? => %d\n" , err); + hdr->operation =ZUFS_OP_BREAK ; + hdr->err = err; + } + +return err; + +err: +put_user (err, (int *)parg); +return err; +} + +static int _try_grab_zt_channel (struct zuf_root_info *zri,int cpu, +struct zufc_thread **ztp) +{ +struct zufc_thread *zt; +int c; + +for (c =0 ; ; ++c) { + zt =_zt_from_cpu (zri, cpu, c); +if (unlikely (!zt || !zt->hdr.file)) +break ; + +if (relay_is_fss_waiting_grab (&zt->relay)) { + *ztp = zt; +return true; + } + } + + *ztp =_zt_from_cpu (zri, cpu,0 ); +return false; +} + +#define _zuf_get_cpu () get_cpu() +#define _zuf_put_cpu () put_cpu() + +#ifdef CONFIG_ZUF_DEBUG +static +int _r_zufs_dispatch(struct zuf_root_info *zri, struct zuf_dispatch_op *zdo) +#else +int __zufc_dispatch(struct zuf_root_info *zri, struct zuf_dispatch_op *zdo) +#endif +{ +struct task_struct *app =get_current (); +struct zufs_ioc_hdr *hdr = zdo->hdr; +int cpu, cpu2; +struct zufc_thread *zt; + +if (unlikely (hdr->out_len && !hdr->out_max)) { +/* TODO: Complain here and let caller code do this proper */ + hdr->out_max = hdr->out_len; + } + +channel_busy: + cpu =_zuf_get_cpu (); + +if (!_try_grab_zt_channel (zri, cpu, &zt)) { +_zuf_put_cpu (); + +/* If channel was grabbed then maybe a break_all is in progress
fs/zuf/zuf-core.c +268
-1+* on a different CPU make sure zt->file on this core is +* updated +*/ +mb (); +if (unlikely (!zt->hdr.file)) { +zuf_err ("[%d] !zt->file\n" , cpu); +return -EIO ; + } +zuf_dbg_err ("[%d] can this be\n" , cpu); +/* FIXME: Do something much smarter */ +msleep (10 ); +if (signal_pending (get_current ())) { +zuf_dbg_err ("[%d] => EINTR\n" , cpu); +return -EINTR ; + } + goto channel_busy; + } + +/* lock app to this cpu while waiting */ +cpumask_copy (&zt->relay.cpus_allowed, &app->cpus_allowed); +cpumask_copy (&app->cpus_allowed,cpumask_of (smp_processor_id ())); + + zt->zdo = zdo; + +_zuf_put_cpu (); + +relay_fss_wakeup_app_wait (&zt->relay,NULL ); + +/* restore cpu affinity after wakeup */ +cpumask_copy (&app->cpus_allowed, &zt->relay.cpus_allowed); + +cpu2 =smp_processor_id (); +if (cpu2 != cpu) +zuf_warn ("App switched cpu1=%u cpu2=%u\n" , cpu, cpu2); + +return zt->hdr.file ? hdr->err : -EIO ; +} + +const char *zuf_op_name (enum e_zufs_operation op) +{ +#define CASE_ENUM_NAME (e) case e: return #e +switch (op) { +CASE_ENUM_NAME (ZUFS_OP_BREAK ); +default : +return "UNKNOWN" ; + } +} + +#ifdef CONFIG_ZUF_DEBUG + +#define MAX_ZT_SEC 5 +int __zufc_dispatch (struct zuf_root_info *zri,struct zuf_dispatch_op *zdo) +{ +u64 t1, t2; +int err; + + t1 =ktime_get_ns (); + err =_r_zufs_dispatch (zri, zdo); + t2 =ktime_get_ns (); + +if ((t2 - t1) >MAX_ZT_SEC *NSEC_PER_SEC ) +zuf_err ("zufc_dispatch(%s, [0x%x-0x%x]) took %lld sec\n" , +zuf_op_name (zdo->hdr->operation), zdo->hdr->offset, + zdo->hdr->len, + (t2 - t1) /NSEC_PER_SEC ); + +return err; +} +#endif /* def CONFIG_ZUF_DEBUG */ + +/* ~~~ iomap_exec && exec_buffer allocation ~~~ */ +struct zu_exec_buff { +struct zuf_special_file hdr; +struct vm_area_struct *vma; +void *opt_buff; +ulong alloc_size; +}; + +/* Do some common checks and conversions */ +static inline struct zu_exec_buff *_ebuff_from_file (struct file *file) +{ +struct zu_exec_buff *ebuff = file->private_data; + +if (WARN_ON_ONCE (ebuff->hdr.type != zlfs_e_dpp_buff)) { +zuf_err ("Must call ZU_IOC_ALLOC_BUFFER first\n" ); +return NULL ; + } + +if (WARN_ON_ONCE (ebuff->hdr.file != file)) +return NULL ; + +return ebuff; +} + +static int _zu_ebuff_alloc (struct file *file,void *arg) +{ +struct zufs_ioc_alloc_buffer ioc_alloc; +struct zu_exec_buff *ebuff; +int err; + + err =copy_from_user (&ioc_alloc, arg,sizeof (ioc_alloc)); +if (unlikely (err)) { +zuf_err ("=>%d\n" , err); +return err; + } + +if (ioc_alloc.init_size > ioc_alloc.max_size) +return -EINVAL ; + +/* TODO: Easily Support growing */ +/* TODO: Support global pools, also easy */ +if (ioc_alloc.pool_no || ioc_alloc.init_size != ioc_alloc.max_size) +return -ENOTSUPP ; + + ebuff =kzalloc (sizeof (*ebuff),GFP_KERNEL ); +if (unlikely (!ebuff)) +return -ENOMEM ; + + ebuff->hdr.type = zlfs_e_dpp_buff; + ebuff->hdr.file = file; +i_size_write (file->f_inode, ioc_alloc.max_size); + ebuff->alloc_size = ioc_alloc.init_size; + ebuff->opt_buff =vmalloc (ioc_alloc.init_size); +if (unlikely (!ebuff->opt_buff)) { +kfree (ebuff); +return -ENOMEM ; + } +_fill_buff (ebuff->opt_buff, ioc_alloc.init_size /sizeof (ulong)); + + file->private_data = &ebuff->hdr; +return 0 ; +} + +static void zufc_ebuff_release (struct file *file) +{ +struct zu_exec_buff *ebuff =_ebuff_from_file (file); + +if (unlikely (!ebuff)) +return ; + +vfree (ebuff->opt_buff); + ebuff->hdr.type =0 ; + ebuff->hdr.file =NULL ;/* for none-dbg Kernels && use-after-free */ +kfree (ebuff); +} + +static int _zu_break (struct file *filp,void *parg) +{ +struct zuf_root_info *zri =ZRI (filp->f_inode->i_sb); +int i, c; + +zuf_dbg_core ("enter\n" ); +mb ();/* TODO how to schedule on all CPU's */ + +for (i =0 ; i < zri->_ztp->_max_zts; ++i) { +for (c =0 ; c < zri->_ztp->_max_channels; ++c) { +struct zufc_thread *zt =_zt_from_cpu (zri, i, c); + +if (unlikely (!(zt && zt->hdr.file))) +continue ; +relay_fss_wakeup (&zt->relay); + } + } + +if (zri->mount.zsf.file) +relay_fss_wakeup (&zri->mount.relay); + +zuf_dbg_core ("exit\n" ); +return 0 ; +} +long zufc_ioctl (struct file *file,unsigned int cmd,ulong arg) { +void __user *parg = (void __user *)arg; +switch (cmd) { +case ZU_IOC_REGISTER_FS : +return _zu_register_fs (file, parg); +case ZU_IOC_MOUNT : +return _zu_mount (file, parg); +case ZU_IOC_NUMA_MAP : +return _zu_numa_map (file, parg); +case ZU_IOC_INIT_THREAD : +return _zu_init (file, parg); +case ZU_IOC_WAIT_OPT : +return _zu_wait (file, parg); +case ZU_IOC_ALLOC_BUFFER : +return _zu_ebuff_alloc (file, parg); +case ZU_IOC_BREAK_ALL : +return _zu_break (file, parg);default : -zuf_err ("%d\n" , cmd); +zuf_err ("%d %ld\n" , cmd,ZU_IOC_WAIT_OPT );return -ENOTTY ; } }@@ -38,11 +844,215 @@ int zufc_release(struct inode *inode, struct file *file)return 0 ;switch (zsf->type) { +case zlfs_e_zt: +zufc_zt_release (file); +return 0 ; +case zlfs_e_mout_thread: +zufc_mounter_release (file); +return 0 ; +case zlfs_e_pmem: +/* NOTHING to clean for pmem file yet */ +/* zuf_pmem_release(file);*/ +return 0 ; +case zlfs_e_dpp_buff: +zufc_ebuff_release (file); +return 0 ;default :return 0 ; } } +/* ~~~~ mmap area of app buffers into server ~~~~ */ + +static int zuf_zt_fault (struct vm_fault *vmf) +{ +zuf_err ("should not fault\n" ); +return VM_FAULT_SIGBUS ; +} + +static const struct vm_operations_struct zuf_vm_ops = { + .fault = zuf_zt_fault, +}; + +static int _zufc_zt_mmap (struct file *file,struct vm_area_struct *vma, +struct zufc_thread *zt) +{ +/* Tell Kernel We will only access on a single core */ + vma->vm_flags |=VM_MIXEDMAP ; + vma->vm_ops = &zuf_vm_ops; + + zt->vma = vma; + +zuf_dbg_core ( + "[0x%lx] start=0x%lx end=0x%lx flags=0x%lx file- start=0x%lx\n", + _zt_pr_no(zt), vma->vm_start, vma->vm_end, vma->vm_flags, + vma->vm_pgoff); + +return 0 ; +} + +/* ~~~~ mmap the Kernel allocated IOCTL buffer per ZT ~~~~ */ +static int _opt_buff_mmap (struct vm_area_struct *vma,void *opt_buff, +ulong opt_size) +{ +ulong offset; + +if (!opt_buff) +return -ENOMEM ; + +for (offset =0 ; offset < opt_size; offset +=PAGE_SIZE ) { +ulong addr = vma->vm_start + offset; +ulong pfn =vmalloc_to_pfn (opt_buff + offset); +pfn_t pfnt =phys_to_pfn_t (PFN_PHYS (pfn),PFN_MAP |PFN_DEV ); +int err; + +zuf_dbg_verbose ("[0x%lx] pfn-0x%lx addr=0x%lx buff=0x%lx\n" , + offset, pfn, addr, (ulong )opt_buff + offset); + + err =zuf_flt_to_err (vmf_insert_mixed_mkwrite (vma, addr, pfnt)); +if (unlikely (err)) { + zuf_err("zuf: zuf_insert_mixed_mkwrite => %d offset=0x%lx addr=0x%lx\n", + err, offset, addr); +return err; + } + } + +return 0 ; +} + +static int zuf_obuff_fault (struct vm_fault *vmf) +{ +struct vm_area_struct *vma = vmf->vma; +struct zufc_thread *zt =_zt_from_f_private (vma->vm_file); +long offset = (vmf->pgoff <<PAGE_SHIFT ) -ZUS_API_MAP_MAX_SIZE ; +int err; + + zuf_dbg_core( + "[0x%lx] start=0x%lx end=0x%lx file-start=0x%lxoffset=0x%lx\n",
fs/zuf/zuf-core.c +6
-0+_zt_pr_no (zt), vma->vm_start, vma->vm_end, vma->vm_pgoff, + offset); + +/* if Server overruns its buffer crash it dead */ +if (unlikely ((offset <0 ) || (zt->max_zt_command < offset))) { + zuf_err("[0x%lx] start=0x%lx end=0x%lx file-start=0x%lxoffset=0x%lx\n",
fs/zuf/zuf-core.c +33
-0+_zt_pr_no (zt), vma->vm_start, + vma->vm_end, vma->vm_pgoff, offset); +return VM_FAULT_SIGBUS ; + } + +/* We never released a zus-core.c that does not fault the +* first page first. I want to see if this happens +*/ +if (unlikely (offset)) +zuf_warn ("Suspicious server activity\n" ); + +/* This faults only once at very first access */ + err =_opt_buff_mmap (vma, zt->opt_buff, zt->max_zt_command); +if (unlikely (err)) +return VM_FAULT_SIGBUS ; + +return VM_FAULT_NOPAGE ; +} + +static const struct vm_operations_struct zuf_obuff_ops = { + .fault = zuf_obuff_fault, +}; + +static int _zufc_obuff_mmap (struct file *file,struct vm_area_struct *vma, +struct zufc_thread *zt) +{ + vma->vm_flags |=VM_MIXEDMAP ; + vma->vm_ops = &zuf_obuff_ops; + + zt->opt_buff_vma = vma; + + zuf_dbg_core( + "[0x%lx] start=0x%lx end=0x%lx flags=0x%lx file-start=0x%lx\n",
fs/zuf/zuf-core.c +42
-0+_zt_pr_no (zt), vma->vm_start, vma->vm_end, vma->vm_flags, + vma->vm_pgoff); + +return 0 ; +} + +/* ~~~ */ + +static int zufc_zt_mmap (struct file *file,struct vm_area_struct *vma) +{ +struct zufc_thread *zt =_zt_from_f_private (file); + +/* We have two areas of mmap in this special file. +* 0 to ZUS_API_MAP_MAX_SIZE: +* The first part where app pages are mapped +* into server per operation. +* ZUS_API_MAP_MAX_SIZE of size zuf_root_info->max_zt_command +* Is where we map the per ZT ioctl-buffer, later passed +* to the zus_ioc_wait IOCTL call +*/ +if (vma->vm_pgoff ==ZUS_API_MAP_MAX_SIZE /PAGE_SIZE ) +return _zufc_obuff_mmap (file, vma, zt); + +/* zuf ZT API is very particular about where in its +* special file we communicate +*/ +if (unlikely (vma->vm_pgoff)) +return -EINVAL ; + +return _zufc_zt_mmap (file, vma, zt); +} + +/* ~~~~ Implementation of the ZU_IOC_ALLOC_BUFFER mmap facility ~~~~ */ + +static int zuf_ebuff_fault (struct vm_fault *vmf) +{ +struct vm_area_struct *vma = vmf->vma; +struct zu_exec_buff *ebuff =_ebuff_from_file (vma->vm_file); +long offset = (vmf->pgoff <<PAGE_SHIFT ); +int err; + + zuf_dbg_core("start=0x%lx end=0x%lx file-start=0x%lx file-off=0x%lx\n",
fs/zuf/zuf-core.c +5
-0+ vma->vm_start, vma->vm_end, vma->vm_pgoff, offset); + +/* if Server overruns its buffer crash it dead */ +if (unlikely ((offset <0 ) || (ebuff->alloc_size < offset))) { + zuf_err("start=0x%lx end=0x%lx file-start=0x%lx file-off=0x%lx\n",
fs/zuf/zuf-core.c +34
-0+ vma->vm_start, vma->vm_end, vma->vm_pgoff, + offset); +return VM_FAULT_SIGBUS ; + } + +/* We never released a zus-core.c that does not fault the +* first page first. I want to see if this happens +*/ +if (unlikely (offset)) +zuf_warn ("Suspicious server activity\n" ); + +/* This faults only once at very first access */ + err =_opt_buff_mmap (vma, ebuff->opt_buff, ebuff->alloc_size); +if (unlikely (err)) +return VM_FAULT_SIGBUS ; + +return VM_FAULT_NOPAGE ; +} + +static const struct vm_operations_struct zuf_ebuff_ops = { + .fault = zuf_ebuff_fault, +}; + +static int zufc_ebuff_mmap (struct file *file,struct vm_area_struct *vma) +{ +struct zu_exec_buff *ebuff =_ebuff_from_file (vma->vm_file); + + vma->vm_flags |=VM_MIXEDMAP ; + vma->vm_ops = &zuf_ebuff_ops; + + ebuff->vma = vma; + + zuf_dbg_core("start=0x%lx end=0x%lx flags=0x%lx file-start=0x%lx\n", + vma->vm_start, vma->vm_end, vma->vm_flags, vma-Quoted 1 line
vm_pgoff);fs/zuf/zuf-core.c +8
-0+ +return 0 ; +} +int zufc_mmap (struct file *file,struct vm_area_struct *vma) {struct zuf_special_file *zsf = file->private_data;@@ -53,6 +1063,10 @@ int zufc_mmap(struct file *file, struct vm_area_struct *vma) }switch (zsf->type) { +case zlfs_e_zt: +return zufc_zt_mmap (file, vma); +case zlfs_e_dpp_buff: +return zufc_ebuff_mmap (file, vma);default :zuf_err ("type=%d\n" , zsf->type);return -ENOTTY;fs/zuf/zuf-root.c +7
-0@@ -227,6 +227,7 @@ static void zufr_put_super(struct super_block *sb) {struct zuf_root_info *zri =ZRI (sb); +zufc_zts_fini (zri);_unregister_all_fses (zri);zuf_info ("zuf_root umount\n" );@@ -282,10 +283,16 @@ static int zufr_fill_super(struct super_block *sb, void *data, int silent) root_i->i_fop = &zufr_file_dir_operations; root_i->i_op = &zufr_inode_operations; +spin_lock_init (&zri->mount.lock);mutex_init (&zri->sbl_lock); +relay_init (&zri->mount.relay);INIT_LIST_HEAD (&zri->fst_list);INIT_LIST_HEAD (&zri->pmem_list); + err =zufc_zts_init (zri); +if (unlikely (err)) +return err;/* put will be called we have a root */ +return 0 ; }fs/zuf/zuf.h +46
-0@@ -23,9 +23,11 @@#include <linux/xattr.h> #include <linux/exportfs.h> #include <linux/page_ref.h> +#include <linux/mm.h> #include "zus_api.h" +#include "relay.h" #include "_pr.h" enum zlfs_e_special_file {@@ -44,6 +46,8 @@ struct zuf_special_file {struct zuf_root_info {struct __mount_thread_info {struct zuf_special_file zsf; +spinlock_t lock; +struct relay relay;struct zufs_ioc_mount *zim; } mount;@@ -102,6 +106,48 @@ static inline struct zuf_inode_info *ZUII(struct inode *inode) return container_of(inode, struct zuf_inode_info, vfs_inode); } +static inline struct zuf_fs_type *ZUF_FST (struct file_system_type *fs_type) +{ + return container_of(fs_type, struct zuf_fs_type, vfs_fst); +} + +static inline struct zuf_fs_type *zuf_fst (struct super_block *sb) +{ +return ZUF_FST (sb->s_type); +} + +struct zuf_dispatch_op ; +typedef int (*overflow_handler )(struct zuf_dispatch_op *zdo,void *parg, +ulong zt_max_bytes); +struct zuf_dispatch_op { +struct zufs_ioc_hdr *hdr; +struct page **pages; +uint nump; +overflow_handler oh; +struct super_block *sb; +struct inode *inode; +}; + +static inline void +zuf_dispatch_init (struct zuf_dispatch_op *zdo,struct zufs_ioc_hdr *hdr, +struct page **pages,uint nump) +{ +memset (zdo,0 ,sizeof (*zdo)); + zdo->hdr = hdr; + zdo->pages = pages; zdo->nump = nump; +} + +static inline int zuf_flt_to_err (vm_fault_t flt) +{ +if (likely (flt ==VM_FAULT_NOPAGE )) +return 0 ; + +if (flt ==VM_FAULT_OOM ) +return -ENOMEM ; + +return -EACCES ; +} +/* Keep this include last thing in file */ #include "_extern.h" fs/zuf/zus_api.h +185
-0@@ -66,6 +66,47 @@#endif /* ndef __KERNEL__ */ +/* first available error code after include/linux/errno.h */ +#define EZUFS_RETRY 531 + +/* The below is private to zuf Kernel only. Is not exposed to VFS nor zus +* (defined here to allocate the constant) +*/ +#define EZUF_RETRY_DONE 540 + +/** +* zufs dual port memory +* This is a special type of offset to either memory or persistent-memory, +* that is designed to be used in the interface mechanism between userspace +* and kernel, and can be accessed by both. +* 3 first bits denote a mem-pool: +* 0 - pmem pool +* 1-6 - established shared pool by a call to zufs_ioc_create_mempool (below) +* 7 - offset into app memory +*/ +typedef __u64 __bitwise zu_dpp_t ; + +static inline uint zu_dpp_t_pool (zu_dpp_t t) +{ +return t &0x7 ; +} + +static inline ulong zu_dpp_t_val (zu_dpp_t t) +{ +return t & ~0x7 ; +} + +static inline zu_dpp_t enc_zu_dpp_t (ulong v,uint pool) +{ +return v | pool; +} + +/* ~~~~~ ZUFS API ioctl commands ~~~~~ */ +enum { +ZUS_API_MAP_MAX_PAGES =1024 , +ZUS_API_MAP_MAX_SIZE =ZUS_API_MAP_MAX_PAGES *PAGE_SIZE , +}; +struct zufs_ioc_hdr {__u32 err;/* IN/OUT must be first */ __u16 in_len;/* How much to be copied *to* zus */ @@ -102,4 +143,148 @@ struct zufs_ioc_register_fs { };#define ZU_IOC_REGISTER_FS _IOWR('Z', 10, struct zufs_ioc_register_fs) +/* A cookie from user-mode returned by mount */ +struct zus_sb_info ; + +/* zus cookie per inode */ +struct zus_inode_info ; + +enum ZUFS_M_FLAGS { +ZUFS_M_PEDANTIC =0x00000001 , +ZUFS_M_EPHEMERAL =0x00000002 , +ZUFS_M_SILENT =0x00000004 , +}; + +struct zufs_parse_options { +__u32 mount_options_len; +__u32 pedantic; +__u64 mount_flags; +char mount_options[0 ]; +}; + +enum e_mount_operation { +ZUFS_M_MOUNT =1 , +ZUFS_M_UMOUNT , +ZUFS_M_REMOUNT , +ZUFS_M_DDBG_RD , +ZUFS_M_DDBG_WR , +}; + +struct zufs_mount_info { +/* IN */ +struct zus_fs_info *zus_zfi; +__u16 num_cpu; +__u16 num_channels; +__u32 pmem_kern_id; +__u64 sb_id; + +/* OUT */ +struct zus_sb_info *zus_sbi; +/* mount is also iget of root */ +struct zus_inode_info *zus_ii; +zu_dpp_t _zi; +__u64 old_mount_opt; +__u64 remount_flags; + +/* More FS specific info */ +__u32 s_blocksize_bits; +__u8 acl_on; +struct zufs_parse_options po; +}; + +/* mount / umount */ +struct zufs_ioc_mount { +struct zufs_ioc_hdr hdr; +struct zufs_mount_info zmi; +}; +#define ZU_IOC_MOUNT _IOWR('Z', 11, struct zufs_ioc_mount) + +/* pmem */ +struct zufs_ioc_numa_map { +/* Set by zus */ +struct zufs_ioc_hdr hdr; + +__u32 possible_nodes; +__u32 possible_cpus; +__u32 online_nodes; +__u32 online_cpus; + +__u32 max_cpu_per_node; + +/* This indicates that NOT all nodes have @max_cpu_per_node cpus */ +bool nodes_not_symmetrical; + +/* Variable size must keep last +* size @online_cpus +*/ +__u8 cpu_to_node[]; +}; +#define ZU_IOC_NUMA_MAP _IOWR('Z', 12, struct zufs_ioc_numa_map) + +/* ZT init */ +enum {ZUFS_MAX_ZT_CHANNELS =64 }; + +struct zufs_ioc_init { +struct zufs_ioc_hdr hdr; +ulong affinity;/* IN */ +uint channel_no; +uint max_command; +}; +#define ZU_IOC_INIT_THREAD _IOWR('Z', 14, struct zufs_ioc_init) + +/* break_all (Server telling kernel to clean) */ +struct zufs_ioc_break_all { +struct zufs_ioc_hdr hdr; +}; +#define ZU_IOC_BREAK_ALL _IOWR('Z', 15, struct zufs_ioc_break_all) + +/* ~~~ zufs_ioc_wait_operation ~~~ */ +struct zufs_ioc_wait_operation { +struct zufs_ioc_hdr hdr; +/* maximum size is governed by zufs_ioc_init->max_command */ +char opt_buff[]; +}; +#define ZU_IOC_WAIT_OPT _IOWR('Z', 16, struct zufs_ioc_wait_operation) + +/* These are the possible operations sent from Kernel to the Server in the +* return of the ZU_IOC_WAIT_OPT. +*/ +enum e_zufs_operation { +ZUFS_OP_NULL =0 , + +ZUFS_OP_BREAK ,/* Kernel telling Server to exit */ +ZUFS_OP_MAX_OPT , +}; + +/* Allocate a special_file that will be a dual-port communication buffer with +* user mode. +* Server will access the buffer via the mmap of this file. +* Kernel will access the file via the valloc() pointer +* +* Some IOCTLs below demand use of this kind of buffer for communication +* TODO: +* pool_no is if we want to associate this buffer onto the 6 possible +* mem-pools per zuf_sbi. So anywhere we have a zu_dpp_t it will mean +* access from this pool. +* If pool_no is zero then it is private to only this file. In this case +* sb_id && zus_sbi are ignored / not needed. +*/ +struct zufs_ioc_alloc_buffer { +struct zufs_ioc_hdr hdr; +/* The ID of the super block received in mount */ +__u64 sb_id; +/* We verify the sb_id validity against zus_sbi */ +struct zus_sb_info *zus_sbi; +/* max size of buffer allowed (size of mmap) */ +__u32 max_size; +/* allocate this much on initial call and set into vma */ +__u32 init_size; + +/* TODO: These below are now set to ZERO. Need implementation */ +__u16 pool_no; +__u16 flags; +__u32 reserved; +}; +#define ZU_IOC_ALLOC_BUFFER _IOWR('Z', 17, struct zufs_ioc_init) +#endif /*
_LINUX_ZUFS_API_H*/
--
2.20.1
Re: [RFC PATCH 01/17] fs: Add the ZUF filesystem to the build + License
In reply to Schumaker, AnnaQuoted 1 line · Anna
On Tue, 2019-02-19 at 13:51 +0200, Boaz harrosh wrote:
<>
Quoted 10 lines
fs/zuf/Kconfig line 1
Quoted 7 lines
fs/zuf/Kconfig new file +1
-0@@ -0,0 +1,28 @@ +menuconfig ZUFShouldn't this be "
CONFIG_ZUF_FS" to stay consistent with other filesystems?
Totally sure will change maybe ZUFS though? I'll look what's common
Quoted 6 lines
Quoted 6 lines
fs/zuf/Kconfig new file +6
-0+ tristate "ZUF - Zero-copy User-mode Feeder" + depends on BLOCK + depends on ZONE_DEVICE + select CRC16 + select MEMCG + help
Quoted 8 lines
fs/zuf/Kconfig line 15
Quoted 8 lines
fs/zuf/Kconfig new file +8
-0+ ZUFS Kernel part. + To enable say Y here. + + To compile this as a module, choose M here: the module will be + called zuf.ko + +if ZUF +
<>
Re: [RFC PATCH 04/17] zuf: zuf-core The ZTs
In reply to Schumaker, AnnaQuoted 1 line · Anna
On Tue, 2019-02-19 at 13:51 +0200, Boaz harrosh wrote:
<>
Quoted 9 lines
Quoted 9 lines
zuf-core established the communication channels with the ZUS User Mode Server.
In this patch we have the core communication mechanics. Which is the Novelty of this project.
(See previous submitted documentation for more info)Users will come later in the patchset
<>
Quoted 4 lines
Quoted 4 lines
fs/zuf/relay.h new file +4
-0+static inline int relay_fss_wait (struct relay *relay) +{ +int err; +
Quoted 9 lines
fs/zuf/relay.h line 56
Quoted 5 lines
fs/zuf/relay.h new file +5
-0+ relay->fss_waiting = true; + relay->fss_wakeup = false; + err =wait_event_interruptible (relay->fss_wq, relay->fss_wakeup); + +return err;Could you just do: "return
wait_event_interruptible()" directly, instead of using the err variable?
Totally there used to be a dbg_print here there for the reminder of that time Will change ...
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+} +
<>
Quoted 8 lines
Quoted 8 lines
fs/zuf/zuf-core.c +8
-0+static struct zufc_thread *_zt_from_cpu (struct zuf_root_info *zri, +int cpu,uint chan) +{ +return per_cpu_ptr (zri->_ztp->_all_zt[chan], cpu); +} + +static int _zt_from_f (struct file *filp,int cpu,uint chan, +struct zufc_thread **ztp)
Quoted 9 lines
fs/zuf/zuf-core.c line 115
Quoted 5 lines
fs/zuf/zuf-core.c +5
-0+{ + *ztp =_zt_from_cpu (ZRI (filp->f_inode->i_sb), cpu, chan); +if (unlikely (!*ztp)) +return -ERANGE ; +return 0 ;I'm curious if there is a reason you did it this way instead of making use of the
ERR_PTR()macro to return ztp directly?
For one now looking at it I hate the name its wrong. I will change that. It is done like that because it used to be used in many places and I did not want every place to have its print and invent its own error code.
But now it has a single user I might just fold it into its only user. All other places must use _zt_from_f_private. Cool I'll kill it.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+} +
<>
Thanks, will fix
Boaz
Quoted 59 lines
Quoted 59 lines
fs/zuf/zuf-core.c +59
-0+static int _zu_init (struct file *file,void *parg) +{ +struct zufc_thread *zt; +int cpu =smp_processor_id (); +struct zufs_ioc_init zi_init; +int err; + + err =copy_from_user (&zi_init, parg,sizeof (zi_init)); +if (unlikely (err)) { +zuf_err ("=>%d\n" , err); +return err; + } +if (unlikely (zi_init.channel_no >=ZUFS_MAX_ZT_CHANNELS )) { +zuf_err ("[%d] channel_no=%d\n" , cpu, zi_init.channel_no); +return -EINVAL ; + } + +zuf_dbg_zus ("[%d] aff=0x%lx channel=%d\n" , + cpu, zi_init.affinity, zi_init.channel_no); + + zi_init.hdr.err =_zt_from_f (file, cpu, zi_init.channel_no, &zt); +if (unlikely (zi_init.hdr.err)) { +zuf_err ("=>%d\n" , err); + goto out; + } + +if (unlikely (zt->hdr.file)) { + zi_init.hdr.err = -EINVAL ; +zuf_err ("[%d] !!! thread already set\n" , cpu); + goto out; + } + +relay_init (&zt->relay); + zt->hdr.type = zlfs_e_zt; + zt->hdr.file = file; + zt->no = cpu; + zt->chan = zi_init.channel_no; + + zt->max_zt_command = zi_init.max_command; + zt->opt_buff =vmalloc (zi_init.max_command); +if (unlikely (!zt->opt_buff)) { + zi_init.hdr.err = -ENOMEM ; + goto out; + } +_fill_buff (zt->opt_buff, zi_init.max_command /sizeof (ulong)); + + file->private_data = &zt->hdr; +out: + err =copy_to_user (parg, &zi_init,sizeof (zi_init)); +if (err) +zuf_err ("=>%d\n" , err); +return err; +} + +struct zufc_thread *_zt_from_f_private (struct file *file) +{ +struct zuf_special_file *zsf = file->private_data; + +WARN_ON (zsf->type != zlfs_e_zt);
Quoted 8 lines
fs/zuf/zuf-core.c line 456
Quoted 8 lines
fs/zuf/zuf-core.c +8
-0+ return container_of(zsf, struct zufc_thread, hdr); +} + +/* Caller checks that file->private_data != NULL */ +static void zufc_zt_release (struct file *file) +{ +struct zufc_thread *zt =_zt_from_f_private (file); +
<>