mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
Merge tag 'vfs-7.4-rc1.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull misc vfs updates from Christian Brauner:
"Fixes:
- aio: a keyed poll completion on an epoll instance could recurse
into the same epoll waitqueue lock when the result eventfd is
watched by that very instance. An unprivileged process could make a
CPU spin on the recursive lock. eventfd-backed poll completions are
always deferred now.
- fsnotify_inoderemove() is only called once the inode is really
dead, no nlink and no aliases, and open_by_handle_at() can't add an
alias to a dead inode anymore. The race could crash fsnotify or
lose inode mark notifications.
- devtmpfs: the conversion of the public instance to ->get_tree()
broke reconfiguring the shared superblock's options on later mounts
which made the boot time defaults permanent. A reconfigure context
is kept in fc->fs_private so the parse ops can forward options to
the underlying filesystem.
- ufs truncated the 64-bit directory size to an unsigned int in
ufs_last_byte(). A crafted image with a 4 GiB directory produced an
out-of-folio read in ufs_find_entry() and, with
CONFIG_UFS_FS_WRITE, a write into an adjacent page.
- devpts rejects max=0 instead of silently lifting the per-instance
pty limit. The value wrapped into ida_alloc_max() and became
unlimited.
- fs_pin publishes pins with the rcu list helpers so the kill paths
reading the lists under rcu see the initialization.
- dentry_kill() reports a Tasks-RCU quiescent state. Its
cond_resched() is the only reschedule point on the dentry teardown
path and cond_resched() isn't a quiescent state for Tasks-RCU, so
Meta kept seeing rcu_tasks stalls in btrfs subvolume deletion.
- writeback sizes foreign flushes by the target wb's dirty pages
instead of the memcg-wide count which over or undersized a single
bdi flush.
- nfsd READ emitted two fsnotify access events on the iterator path
since vfs_iocb_iter_read() already sends one. A READ on a krb5i or
krb5p mount showed up twice in inotify.
- pipe and splice pass a poll key when waking readers and writers so
epoll, poll() and select() waiters only wake for the event they
asked for.
- the iso8859-14 Unicode to charset tables had page01 duplicated as
page1e so 29 code points mapped to the wrong bytes and 22 that
aren't in the charset were accepted.
- orangefs doesn't wait for an unmount service operation that never
returns on system shutdown and uses ssize_t for strscpy() errors.
- __register_chrdev() checks the kobject_set_name() return value.
- selftest fixes: the openat2 tests hardcoded O_LARGEFILE to 0x8000
which is O_NOFOLLOW on powerpc, resolve_test makes /tmp a
mountpoint so RESOLVE_NO_XDEV has a boundary to trip over,
file_stressor moves into its own directory with a 30 minute
timeout, the kernfs listxattr test skips when SELinux exposes
security.selinux, the namespaces active reference tests wait for
the thread via a PIDFD_THREAD pidfd since pthread_join() returns
before exit_nsproxy_namespaces(), the idmapped_tmpfile test chowns
its directory into the mapped range, the clone3 CLONE_CLEAR_SIGHAND
test adds CLONE_VM so it fails for the intended reason, the pidfd
PPID error message prints the values it compares and fscontext_ns
gets a .gitignore.
Cleanups:
- vmcore prints the release of the crashed kernel from the VMCOREINFO
note so a kdump that dies before the dump lands still says which
kernel it was for.
- initramfs allocates hardlink hash entries with the validated cpio
name length instead of PATH_MAX, which put every entry in
kmalloc-8k.
- the unused dax_layout_busy_page() is removed,
dax_layout_busy_page_range() becomes static and dax_folio_init()
drops a redundant list initialization.
- vfs_empty_path() is removed, it has had no callers since
getname_maybe_null().
- comment and documentation fixes in aio, bpf_fs_kfuncs,
fs-writeback, inode, read_write, squashfs and the vfs.rst copy of
struct file_system_type"
* tag 'vfs-7.4-rc1.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (38 commits)
selftests/filesystems: Fix idmapped_tmpfile layer dir ownership
selftests/namespaces: Wait for thread exit via pidfd in active-ref tests
writeback: size foreign flushes by target wb dirty pages
initramfs: Reduce hardlink hash allocation sizes
fs: remove unused vfs_empty_path()
dcache: report a Tasks-RCU quiescent state in dentry_kill()
vmcore: report the release of the crashed kernel
splice: pass a poll key when waking pipe readers and writers
pipe: pass a poll key when waking writers after a resize
orangefs: use ssize_t instead of size_t for error codes...
orangefs_super: don't wait on service operation on system shutdown.
docs/vfs: Fix the struct file_system_type copy
nls: fix the Unicode to charset tables of iso8859-14
selftests/filesystems/openat2: make /tmp a mountpoint inside private namespace
selftests/filesystems/openat2: fix O_LARGEFILE definitions for non-arm64 architectures
fs: fix misleading comments in read_write.c
squashfs: fix inode number description in documentation
fs: fix typos in comments
fs/dax: Make dax_layout_busy_page_range() static
fs/dax: Remove unused dax_layout_busy_page()
...
This commit is contained in:
@@ -177,9 +177,9 @@ or if the compressed block was larger than the uncompressed block.
|
||||
|
||||
Inodes are packed into the metadata blocks, and are not aligned to block
|
||||
boundaries, therefore inodes overlap compressed blocks. Inodes are identified
|
||||
by a 48-bit number which encodes the location of the compressed metadata block
|
||||
containing the inode, and the byte offset into that block where the inode is
|
||||
placed (<block, offset>).
|
||||
by a 64-bit number: the upper 48 bits encode the location of the compressed
|
||||
metadata block containing the inode, and the lower 16 bits give the byte offset
|
||||
into that block where the inode is placed (<block, offset>).
|
||||
|
||||
To maximise compression there are different inodes for each file type
|
||||
(regular file, directory, device, etc.), the inode contents and length
|
||||
|
||||
@@ -117,7 +117,7 @@ members are defined:
|
||||
const struct fs_parameter_spec *parameters;
|
||||
void (*kill_sb) (struct super_block *);
|
||||
struct module *owner;
|
||||
struct file_system_type * next;
|
||||
struct hlist_node list;
|
||||
struct hlist_head fs_supers;
|
||||
|
||||
struct lock_class_key s_lock_key;
|
||||
|
||||
+64
-44
@@ -72,39 +72,90 @@ static struct file_system_type internal_fs_type = {
|
||||
.kill_sb = kill_anon_super,
|
||||
};
|
||||
|
||||
/* Simply take a ref on the existing mount */
|
||||
struct devtmpfs_context {
|
||||
struct fs_context *fc;
|
||||
};
|
||||
|
||||
static void devtmpfs_free(struct fs_context *fc)
|
||||
{
|
||||
struct devtmpfs_context *ctx = fc->fs_private;
|
||||
|
||||
if (ctx) {
|
||||
put_fs_context(ctx->fc);
|
||||
kfree(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
static int devtmpfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
|
||||
{
|
||||
struct devtmpfs_context *ctx = fc->fs_private;
|
||||
|
||||
return ctx->fc->ops->parse_param(ctx->fc, param);
|
||||
}
|
||||
|
||||
static int devtmpfs_parse_monolithic(struct fs_context *fc, void *data)
|
||||
{
|
||||
struct devtmpfs_context *ctx = fc->fs_private;
|
||||
|
||||
if (ctx->fc->ops->parse_monolithic)
|
||||
return ctx->fc->ops->parse_monolithic(ctx->fc, data);
|
||||
return generic_parse_monolithic(ctx->fc, data);
|
||||
}
|
||||
|
||||
static int devtmpfs_get_tree(struct fs_context *fc)
|
||||
{
|
||||
struct devtmpfs_context *ctx = fc->fs_private;
|
||||
struct super_block *sb = mnt->mnt_sb;
|
||||
int err;
|
||||
|
||||
atomic_inc(&sb->s_active);
|
||||
down_write(&sb->s_umount);
|
||||
|
||||
if (ctx->fc->ops->reconfigure) {
|
||||
err = ctx->fc->ops->reconfigure(ctx->fc);
|
||||
if (err) {
|
||||
deactivate_locked_super(sb);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
fc->root = dget(sb->s_root);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Ops are filled in during init depending on underlying shmem or ramfs type */
|
||||
static struct fs_context_operations devtmpfs_context_ops = {};
|
||||
static const struct fs_context_operations devtmpfs_context_ops = {
|
||||
.free = devtmpfs_free,
|
||||
.parse_param = devtmpfs_parse_param,
|
||||
.parse_monolithic = devtmpfs_parse_monolithic,
|
||||
.get_tree = devtmpfs_get_tree,
|
||||
};
|
||||
|
||||
/* Call the underlying initialization and set to our ops */
|
||||
static int devtmpfs_init_fs_context(struct fs_context *fc)
|
||||
{
|
||||
int ret;
|
||||
#ifdef CONFIG_TMPFS
|
||||
ret = shmem_init_fs_context(fc);
|
||||
#else
|
||||
ret = ramfs_init_fs_context(fc);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
struct devtmpfs_context *ctx;
|
||||
int err;
|
||||
|
||||
ctx = kzalloc_obj(struct devtmpfs_context);
|
||||
if (!ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Each mount will reconfigure the shared superblock w/ new options */
|
||||
ctx->fc = fs_context_for_reconfigure(mnt->mnt_root,
|
||||
mnt->mnt_sb->s_flags, MS_RMT_MASK);
|
||||
if (IS_ERR(ctx->fc)) {
|
||||
err = PTR_ERR(ctx->fc);
|
||||
kfree(ctx);
|
||||
return err;
|
||||
}
|
||||
|
||||
fc->fs_private = ctx;
|
||||
fc->ops = &devtmpfs_context_ops;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct file_system_type dev_fs_type = {
|
||||
.name = "devtmpfs",
|
||||
.name = "devtmpfs",
|
||||
.init_fs_context = devtmpfs_init_fs_context,
|
||||
};
|
||||
|
||||
@@ -442,31 +493,6 @@ static int __ref devtmpfsd(void *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the underlying (shmem/ramfs) context ops to build ours
|
||||
*/
|
||||
static int devtmpfs_configure_context(void)
|
||||
{
|
||||
struct fs_context *fc;
|
||||
|
||||
fc = fs_context_for_reconfigure(mnt->mnt_root, mnt->mnt_sb->s_flags,
|
||||
MS_RMT_MASK);
|
||||
if (IS_ERR(fc))
|
||||
return PTR_ERR(fc);
|
||||
|
||||
/* Set up devtmpfs_context_ops based on underlying type */
|
||||
devtmpfs_context_ops.free = fc->ops->free;
|
||||
devtmpfs_context_ops.dup = fc->ops->dup;
|
||||
devtmpfs_context_ops.parse_param = fc->ops->parse_param;
|
||||
devtmpfs_context_ops.parse_monolithic = fc->ops->parse_monolithic;
|
||||
devtmpfs_context_ops.get_tree = &devtmpfs_get_tree;
|
||||
devtmpfs_context_ops.reconfigure = fc->ops->reconfigure;
|
||||
|
||||
put_fs_context(fc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create devtmpfs instance, driver-core devices will add their device
|
||||
* nodes here.
|
||||
@@ -482,12 +508,6 @@ int __init devtmpfs_init(void)
|
||||
return PTR_ERR(mnt);
|
||||
}
|
||||
|
||||
err = devtmpfs_configure_context();
|
||||
if (err) {
|
||||
pr_err("unable to configure devtmpfs type %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = register_filesystem(&dev_fs_type);
|
||||
if (err) {
|
||||
pr_err("unable to register devtmpfs type %d\n", err);
|
||||
|
||||
@@ -936,7 +936,7 @@ static int kill_ioctx(struct mm_struct *mm, struct kioctx *ctx,
|
||||
|
||||
/*
|
||||
* exit_aio: called when the last user of mm goes away. At this point, there is
|
||||
* no way for any new requests to be submited or any of the io_* syscalls to be
|
||||
* no way for any new requests to be submitted or any of the io_* syscalls to be
|
||||
* called on the context.
|
||||
*
|
||||
* There may be outstanding kiocbs, but free_ioctx() will explicitly wait on
|
||||
@@ -1280,7 +1280,7 @@ static long aio_read_events_ring(struct kioctx *ctx,
|
||||
* The mutex can block and wake us up and that will cause
|
||||
* wait_event_interruptible_hrtimeout() to schedule without sleeping
|
||||
* and repeat. This should be rare enough that it doesn't cause
|
||||
* peformance issues. See the comment in read_events() for more detail.
|
||||
* performance issues. See the comment in read_events() for more detail.
|
||||
*/
|
||||
sched_annotate_sleep();
|
||||
mutex_lock(&ctx->ring_lock);
|
||||
@@ -1869,7 +1869,12 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
|
||||
list_del_init(&req->wait.entry);
|
||||
list_del(&iocb->ki_list);
|
||||
iocb->ki_res.res = mangle_poll(mask);
|
||||
if (iocb->ki_eventfd && !eventfd_signal_allowed()) {
|
||||
/*
|
||||
* We hold an arbitrary provider waitqueue lock here. Signaling a
|
||||
* result eventfd can feed back through epoll and try to take the same
|
||||
* lock again. Defer all eventfd-backed poll completions.
|
||||
*/
|
||||
if (iocb->ki_eventfd) {
|
||||
iocb = NULL;
|
||||
INIT_WORK(&req->work, aio_poll_put_work);
|
||||
schedule_work(&req->work);
|
||||
|
||||
+2
-2
@@ -237,7 +237,7 @@ int bpf_set_dentry_xattr_locked(struct dentry *dentry, const char *name__str,
|
||||
* @dentry: dentry to get xattr from
|
||||
* @name__str: name of the xattr
|
||||
*
|
||||
* Rmove xattr *name__str* of *dentry*.
|
||||
* Remove xattr *name__str* of *dentry*.
|
||||
*
|
||||
* For security reasons, only *name__str* with prefix "security.bpf."
|
||||
* is allowed.
|
||||
@@ -305,7 +305,7 @@ __bpf_kfunc int bpf_set_dentry_xattr(struct dentry *dentry, const char *name__st
|
||||
* @dentry: dentry to get xattr from
|
||||
* @name__str: name of the xattr
|
||||
*
|
||||
* Rmove xattr *name__str* of *dentry*.
|
||||
* Remove xattr *name__str* of *dentry*.
|
||||
*
|
||||
* For security reasons, only *name__str* with prefix "security.bpf."
|
||||
* is allowed.
|
||||
|
||||
+3
-1
@@ -280,7 +280,9 @@ int __register_chrdev(unsigned int major, unsigned int baseminor,
|
||||
|
||||
cdev->owner = fops->owner;
|
||||
cdev->ops = fops;
|
||||
kobject_set_name(&cdev->kobj, "%s", name);
|
||||
err = kobject_set_name(&cdev->kobj, "%s", name);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = cdev_add(cdev, MKDEV(cd->major, baseminor), count);
|
||||
if (err)
|
||||
|
||||
@@ -469,8 +469,6 @@ static void dax_folio_init(void *entry)
|
||||
|
||||
if (order > 0) {
|
||||
prep_compound_page(&folio->page, order);
|
||||
if (order > 1)
|
||||
INIT_LIST_HEAD(&folio->_deferred_list);
|
||||
WARN_ON_ONCE(folio_ref_count(folio));
|
||||
}
|
||||
}
|
||||
@@ -775,24 +773,23 @@ fallback:
|
||||
|
||||
/**
|
||||
* dax_layout_busy_page_range - find first pinned page in @mapping
|
||||
* @mapping: address space to scan for a page with ref count > 1
|
||||
* @mapping: address space to scan for a pinned page
|
||||
* @start: Starting offset. Page containing 'start' is included.
|
||||
* @end: End offset. Page containing 'end' is included. If 'end' is LLONG_MAX,
|
||||
* pages from 'start' till the end of file are included.
|
||||
*
|
||||
* DAX requires ZONE_DEVICE mapped pages. These pages are never
|
||||
* 'onlined' to the page allocator so they are considered idle when
|
||||
* page->count == 1. A filesystem uses this interface to determine if
|
||||
* any page in the mapping is busy, i.e. for DMA, or other
|
||||
* get_user_pages() usages.
|
||||
* DAX requires ZONE_DEVICE mapped pages. A page is considered busy when
|
||||
* folio_ref_count(folio) exceeds folio_mapcount(folio). This helper is
|
||||
* used to determine if any page in the mapping is busy, i.e. for DMA,
|
||||
* or other get_user_pages() usages.
|
||||
*
|
||||
* It is expected that the filesystem is holding locks to block the
|
||||
* establishment of new mappings in this address_space. I.e. it expects
|
||||
* to be able to run unmap_mapping_range() and subsequently not race
|
||||
* to be able to run unmap_mapping_pages() and subsequently not race
|
||||
* mapping_mapped() becoming true.
|
||||
*/
|
||||
struct page *dax_layout_busy_page_range(struct address_space *mapping,
|
||||
loff_t start, loff_t end)
|
||||
static struct page *dax_layout_busy_page_range(struct address_space *mapping,
|
||||
loff_t start, loff_t end)
|
||||
{
|
||||
void *entry;
|
||||
unsigned int scanned = 0;
|
||||
@@ -844,13 +841,6 @@ struct page *dax_layout_busy_page_range(struct address_space *mapping,
|
||||
xas_unlock_irq(&xas);
|
||||
return page;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dax_layout_busy_page_range);
|
||||
|
||||
struct page *dax_layout_busy_page(struct address_space *mapping)
|
||||
{
|
||||
return dax_layout_busy_page_range(mapping, 0, LLONG_MAX);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dax_layout_busy_page);
|
||||
|
||||
static int __dax_invalidate_entry(struct address_space *mapping,
|
||||
pgoff_t index, bool trunc)
|
||||
|
||||
+25
-4
@@ -451,6 +451,17 @@ static void dentry_free(struct dentry *dentry)
|
||||
call_rcu(&dentry->d_rcu, __d_free);
|
||||
}
|
||||
|
||||
/*
|
||||
* If inode is unlinked and doesn't have any aliases (i.e., all fds pointing to
|
||||
* it are closed), it is pretty much dead. Except that file handle lookup could
|
||||
* still revive it which causes issues to fsnotify. So once inode reaches this
|
||||
* state we make sure to block creating any new aliases.
|
||||
*/
|
||||
static bool inode_notify_dead(struct inode *inode)
|
||||
{
|
||||
return !inode->i_nlink && hlist_empty(&inode->i_dentry);
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the dentry's inode, using the filesystem
|
||||
* d_iput() operation if defined.
|
||||
@@ -460,6 +471,7 @@ static void dentry_unlink_inode(struct dentry * dentry)
|
||||
__releases(dentry->d_inode->i_lock)
|
||||
{
|
||||
struct inode *inode = dentry->d_inode;
|
||||
bool notify_dead;
|
||||
|
||||
raw_write_seqcount_begin(&dentry->d_seq);
|
||||
__d_clear_type_and_inode(dentry);
|
||||
@@ -470,9 +482,10 @@ static void dentry_unlink_inode(struct dentry * dentry)
|
||||
*/
|
||||
dentry->waiters = NULL;
|
||||
raw_write_seqcount_end(&dentry->d_seq);
|
||||
notify_dead = inode_notify_dead(inode);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
spin_unlock(&inode->i_lock);
|
||||
if (!inode->i_nlink)
|
||||
if (notify_dead)
|
||||
fsnotify_inoderemove(inode);
|
||||
if (dentry->d_op && dentry->d_op->d_iput)
|
||||
dentry->d_op->d_iput(dentry, inode);
|
||||
@@ -831,7 +844,7 @@ static struct dentry *dentry_kill(struct dentry *dentry)
|
||||
if (dentry->d_op && dentry->d_op->d_release)
|
||||
dentry->d_op->d_release(dentry);
|
||||
|
||||
cond_resched();
|
||||
cond_resched_tasks_rcu_qs();
|
||||
/* now that it's negative, ->d_parent is stable */
|
||||
if (!IS_ROOT(dentry)) {
|
||||
parent = dentry->d_parent;
|
||||
@@ -2299,7 +2312,12 @@ static struct dentry *__d_obtain_alias(struct inode *inode, bool disconnected)
|
||||
|
||||
sb = inode->i_sb;
|
||||
|
||||
res = d_find_any_alias(inode); /* existing alias? */
|
||||
spin_lock(&inode->i_lock);
|
||||
if (!inode_notify_dead(inode))
|
||||
res = __d_find_any_alias(inode); /* existing alias? */
|
||||
else
|
||||
res = ERR_PTR(-ESTALE);
|
||||
spin_unlock(&inode->i_lock);
|
||||
if (res)
|
||||
goto out;
|
||||
|
||||
@@ -2311,7 +2329,10 @@ static struct dentry *__d_obtain_alias(struct inode *inode, bool disconnected)
|
||||
|
||||
security_d_instantiate(new, inode);
|
||||
spin_lock(&inode->i_lock);
|
||||
res = __d_find_any_alias(inode); /* recheck under lock */
|
||||
if (!inode_notify_dead(inode))
|
||||
res = __d_find_any_alias(inode); /* recheck under lock */
|
||||
else
|
||||
res = ERR_PTR(-ESTALE);
|
||||
if (likely(!res)) { /* still no alias, attach a disconnected dentry */
|
||||
unsigned add_flags = d_flags_for_inode(inode);
|
||||
|
||||
|
||||
@@ -249,6 +249,8 @@ static int devpts_parse_param(struct fs_context *fc, struct fs_parameter *param)
|
||||
case Opt_max:
|
||||
if (result.uint_32 > NR_UNIX98_PTY_MAX)
|
||||
return invalf(fc, "max out of range");
|
||||
if (result.uint_32 == 0)
|
||||
return invalf(fc, "max must be greater than 0");
|
||||
opts->max = result.uint_32;
|
||||
break;
|
||||
}
|
||||
|
||||
+10
-13
@@ -233,7 +233,7 @@ void wb_wait_for_completion(struct wb_completion *done)
|
||||
* Parameters for foreign inode detection, see wbc_detach_inode() to see
|
||||
* how they're used.
|
||||
*
|
||||
* These paramters are inherently heuristical as the detection target
|
||||
* These parameters are inherently heuristical as the detection target
|
||||
* itself is fuzzy. All we want to do is detaching an inode from the
|
||||
* current owner if it's being written to by some other cgroups too much.
|
||||
*
|
||||
@@ -248,7 +248,7 @@ void wb_wait_for_completion(struct wb_completion *done)
|
||||
* to 16 slots. To avoid tiny writes from swinging the decision too much,
|
||||
* writes smaller than 1/8 of avg size are ignored.
|
||||
*/
|
||||
#define WB_FRN_TIME_SHIFT 13 /* 1s = 2^13, upto 8 secs w/ 16bit */
|
||||
#define WB_FRN_TIME_SHIFT 13 /* 1s = 2^13, up to 8 secs w/ 16bit */
|
||||
#define WB_FRN_TIME_AVG_SHIFT 3 /* avg = avg * 7/8 + new * 1/8 */
|
||||
#define WB_FRN_TIME_CUT_DIV 8 /* ignore rounds < avg / 8 */
|
||||
#define WB_FRN_TIME_PERIOD (2 * (1 << WB_FRN_TIME_SHIFT)) /* 2s */
|
||||
@@ -259,7 +259,7 @@ void wb_wait_for_completion(struct wb_completion *done)
|
||||
#define WB_FRN_HIST_THR_SLOTS (WB_FRN_HIST_SLOTS / 2)
|
||||
/* if foreign slots >= 8, switch */
|
||||
#define WB_FRN_HIST_MAX_SLOTS (WB_FRN_HIST_THR_SLOTS / 2 + 1)
|
||||
/* one round can affect upto 5 slots */
|
||||
/* one round can affect up to 5 slots */
|
||||
#define WB_FRN_MAX_IN_FLIGHT 1024 /* don't queue too many concurrently */
|
||||
|
||||
/*
|
||||
@@ -1181,7 +1181,7 @@ int cgroup_writeback_by_id(u64 bdi_id, int memcg_id,
|
||||
struct cgroup_subsys_state *memcg_css;
|
||||
struct bdi_writeback *wb;
|
||||
struct wb_writeback_work *work;
|
||||
unsigned long dirty;
|
||||
long dirty;
|
||||
int ret;
|
||||
|
||||
/* lookup bdi and memcg */
|
||||
@@ -1210,16 +1210,13 @@ int cgroup_writeback_by_id(u64 bdi_id, int memcg_id,
|
||||
}
|
||||
|
||||
/*
|
||||
* The caller is attempting to write out most of
|
||||
* the currently dirty pages. Let's take the current dirty page
|
||||
* count and inflate it by 25% which should be large enough to
|
||||
* flush out most dirty pages while avoiding getting livelocked by
|
||||
* concurrent dirtiers.
|
||||
*
|
||||
* BTW the memcg stats are flushed periodically and this is best-effort
|
||||
* estimation, so some potential error is ok.
|
||||
* The caller is attempting to write out most of the target wb's
|
||||
* currently dirty pages. Size the work from the wb's reclaimable pages
|
||||
* and inflate the count by 25%, which should be large enough to flush
|
||||
* out most dirty pages while avoiding getting livelocked by concurrent
|
||||
* dirtiers.
|
||||
*/
|
||||
dirty = memcg_page_state(mem_cgroup_from_css(memcg_css), NR_FILE_DIRTY);
|
||||
dirty = wb_stat_sum(wb, WB_RECLAIMABLE);
|
||||
dirty = dirty * 10 / 8;
|
||||
|
||||
/* issue the writeback work */
|
||||
|
||||
+5
-4
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include <linux/fs.h>
|
||||
#include <linux/rculist.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/slab.h>
|
||||
#include "internal.h"
|
||||
@@ -22,8 +23,8 @@ void pin_remove(struct fs_pin *pin)
|
||||
void pin_insert(struct fs_pin *pin, struct vfsmount *m)
|
||||
{
|
||||
spin_lock(&pin_lock);
|
||||
hlist_add_head(&pin->s_list, &m->mnt_sb->s_pins);
|
||||
hlist_add_head(&pin->m_list, &real_mount(m)->mnt_pins);
|
||||
hlist_add_head_rcu(&pin->s_list, &m->mnt_sb->s_pins);
|
||||
hlist_add_head_rcu(&pin->m_list, &real_mount(m)->mnt_pins);
|
||||
spin_unlock(&pin_lock);
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ void mnt_pin_kill(struct mount *m)
|
||||
while (1) {
|
||||
struct hlist_node *p;
|
||||
rcu_read_lock();
|
||||
p = READ_ONCE(m->mnt_pins.first);
|
||||
p = rcu_dereference(hlist_first_rcu(&m->mnt_pins));
|
||||
if (!p) {
|
||||
rcu_read_unlock();
|
||||
break;
|
||||
@@ -87,7 +88,7 @@ void group_pin_kill(struct hlist_head *p)
|
||||
while (1) {
|
||||
struct hlist_node *q;
|
||||
rcu_read_lock();
|
||||
q = READ_ONCE(p->first);
|
||||
q = rcu_dereference(hlist_first_rcu(p));
|
||||
if (!q) {
|
||||
rcu_read_unlock();
|
||||
break;
|
||||
|
||||
+1
-1
@@ -1770,7 +1770,7 @@ EXPORT_SYMBOL(ilookup);
|
||||
* function must never block --- find_inode() can block in
|
||||
* __wait_on_freeing_inode() --- or when the caller can not increment
|
||||
* the reference count because the resulting iput() might cause an
|
||||
* inode eviction. The tradeoff is that the @match funtion must be
|
||||
* inode eviction. The tradeoff is that the @match function must be
|
||||
* very carefully implemented.
|
||||
*/
|
||||
struct inode *find_inode_nowait(struct super_block *sb,
|
||||
|
||||
+1
-1
@@ -4272,7 +4272,7 @@ int path_mount(const char *dev_name, const struct path *path,
|
||||
if (flags & SB_MANDLOCK)
|
||||
warn_mandlock();
|
||||
|
||||
/* Default to relatime unless overriden */
|
||||
/* Default to relatime unless overridden */
|
||||
if (!(flags & MS_NOATIME))
|
||||
mnt_flags |= MNT_RELATIME;
|
||||
|
||||
|
||||
+2
-11
@@ -1062,7 +1062,6 @@ static __be32 nfsd_finish_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||
nfsd_stats_io_read_add(nn, fhp->fh_export, host_err);
|
||||
*eof = nfsd_eof_on_read(file, offset, host_err, *count);
|
||||
*count = host_err;
|
||||
fsnotify_access(file);
|
||||
trace_nfsd_read_io_done(rqstp, fhp, offset, *count);
|
||||
return 0;
|
||||
} else {
|
||||
@@ -1087,19 +1086,11 @@ __be32 nfsd_splice_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||
struct file *file, loff_t offset, unsigned long *count,
|
||||
u32 *eof)
|
||||
{
|
||||
struct splice_desc sd = {
|
||||
.len = 0,
|
||||
.total_len = *count,
|
||||
.pos = offset,
|
||||
.u.data = rqstp,
|
||||
};
|
||||
ssize_t host_err;
|
||||
|
||||
trace_nfsd_read_splice(rqstp, fhp, offset, *count);
|
||||
host_err = rw_verify_area(READ, file, &offset, *count);
|
||||
if (!host_err)
|
||||
host_err = splice_direct_to_actor(file, &sd,
|
||||
nfsd_direct_splice_actor);
|
||||
host_err = vfs_splice_to_actor(file, offset, *count,
|
||||
nfsd_direct_splice_actor, rqstp);
|
||||
return nfsd_finish_read(rqstp, fhp, file, offset, count, eof, host_err);
|
||||
}
|
||||
|
||||
|
||||
+12
-14
@@ -138,24 +138,23 @@ static const unsigned char page00[256] = {
|
||||
};
|
||||
|
||||
static const unsigned char page01[256] = {
|
||||
0x00, 0x00, 0xa1, 0xa2, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
|
||||
0x00, 0x00, 0xa6, 0xab, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
|
||||
0x00, 0x00, 0xa4, 0xa5, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xb1, /* 0x18-0x1f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
|
||||
0xb2, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
|
||||
0xb4, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0xb9, /* 0x50-0x57 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
|
||||
0xbb, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
|
||||
0x00, 0x00, 0xd7, 0xf7, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
|
||||
0x00, 0x00, 0x00, 0x00, 0xd0, 0xf0, 0xde, 0xfe, /* 0x70-0x77 */
|
||||
0xaf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
|
||||
|
||||
0xa8, 0xb8, 0xaa, 0xba, 0xbd, 0xbe, 0x00, 0x00, /* 0x80-0x87 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
|
||||
@@ -169,7 +168,7 @@ static const unsigned char page01[256] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
|
||||
0x00, 0x00, 0xac, 0xbc, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */
|
||||
};
|
||||
|
||||
@@ -178,7 +177,7 @@ static const unsigned char page1e[256] = {
|
||||
0x00, 0x00, 0xa6, 0xab, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xb1, /* 0x18-0x1f */
|
||||
0xb2, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
|
||||
@@ -188,9 +187,8 @@ static const unsigned char page1e[256] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
|
||||
0xbb, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
|
||||
0x00, 0x00, 0xd7, 0xf7, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
|
||||
0x00, 0x00, 0x00, 0x00, 0xd0, 0xf0, 0xde, 0xfe, /* 0x70-0x77 */
|
||||
0xaf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
|
||||
0xa8, 0xb8, 0xaa, 0xba, 0xbd, 0xbe, 0x00, 0x00, /* 0x80-0x87 */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
|
||||
|
||||
@@ -238,7 +238,7 @@ void orangefs_debugfs_init(int debug_mask)
|
||||
static void orangefs_kernel_debug_init(void)
|
||||
{
|
||||
static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { };
|
||||
size_t len =
|
||||
ssize_t len =
|
||||
strscpy(k_buffer, kernel_debug_string, sizeof(k_buffer) - 1);
|
||||
|
||||
if (len > 0) {
|
||||
@@ -246,7 +246,8 @@ static void orangefs_kernel_debug_init(void)
|
||||
k_buffer[len + 1] = '\0';
|
||||
} else {
|
||||
strscpy(k_buffer, "none\n");
|
||||
pr_info("%s: overflow 1!\n", __func__);
|
||||
if (len <0)
|
||||
pr_info("%s: overflow 1!\n", __func__);
|
||||
}
|
||||
|
||||
debugfs_create_file_aux_num(ORANGEFS_KMOD_DEBUG_FILE, 0444, debug_dir, k_buffer,
|
||||
@@ -337,7 +338,7 @@ static int help_show(struct seq_file *m, void *v)
|
||||
static void orangefs_client_debug_init(void)
|
||||
{
|
||||
static char c_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { };
|
||||
size_t len =
|
||||
ssize_t len =
|
||||
strscpy(c_buffer, client_debug_string, sizeof(c_buffer) - 1);
|
||||
|
||||
if (len > 0) {
|
||||
@@ -345,7 +346,8 @@ static void orangefs_client_debug_init(void)
|
||||
c_buffer[len + 1] = '\0';
|
||||
} else {
|
||||
strscpy(c_buffer, "none\n");
|
||||
pr_info("%s: overflow! 2\n", __func__);
|
||||
if (len <0)
|
||||
pr_info("%s: overflow! 2\n", __func__);
|
||||
}
|
||||
|
||||
client_debug_dentry = debugfs_create_file_aux_num(
|
||||
|
||||
@@ -383,6 +383,24 @@ static int orangefs_unmount(int id, __s32 fs_id, const char *devname)
|
||||
{
|
||||
struct orangefs_kernel_op_s *op;
|
||||
int r;
|
||||
|
||||
/*
|
||||
* If someone reboots linux without unmounting orangefs first,
|
||||
* don't bother firing off an unmount service operation that
|
||||
* will never complete, or the whole system shutdown
|
||||
* stalls for ORANGEFS_DEFAULT_OP_TIMEOUT_SECS.
|
||||
*/
|
||||
|
||||
if (!__is_daemon_in_service() ||
|
||||
system_state == SYSTEM_HALT ||
|
||||
system_state == SYSTEM_POWER_OFF ||
|
||||
system_state == SYSTEM_RESTART) {
|
||||
gossip_debug(GOSSIP_SUPER_DEBUG,
|
||||
"%s: dirty unmount.\n",
|
||||
__func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
op = op_alloc(ORANGEFS_VFS_OP_FS_UMOUNT);
|
||||
if (!op)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1435,7 +1435,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
|
||||
spin_unlock_irq(&pipe->rd_wait.lock);
|
||||
|
||||
/* This might have made more room for writers */
|
||||
wake_up_interruptible(&pipe->wr_wait);
|
||||
wake_up_interruptible_poll(&pipe->wr_wait, EPOLLOUT | EPOLLWRNORM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1709,6 +1709,24 @@ static void vmcore_free_device_dumps(void)
|
||||
#endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */
|
||||
}
|
||||
|
||||
#define VMCOREINFO_OSRELEASE_KEY "OSRELEASE="
|
||||
|
||||
static void __init vmcore_report_crashed_release(void)
|
||||
{
|
||||
const char *ver, *eol;
|
||||
|
||||
ver = strnstr(elfnotes_buf, VMCOREINFO_OSRELEASE_KEY, elfnotes_sz);
|
||||
if (!ver)
|
||||
return;
|
||||
|
||||
ver += sizeof(VMCOREINFO_OSRELEASE_KEY) - 1;
|
||||
eol = memchr(ver, '\n', elfnotes_buf + elfnotes_sz - ver);
|
||||
if (!eol)
|
||||
return;
|
||||
|
||||
pr_notice("dump is from kernel %.*s\n", (int)(eol - ver), ver);
|
||||
}
|
||||
|
||||
/* Init function for vmcore module. */
|
||||
static int __init vmcore_init(void)
|
||||
{
|
||||
@@ -1733,6 +1751,8 @@ static int __init vmcore_init(void)
|
||||
elfcorehdr_free(elfcorehdr_addr);
|
||||
elfcorehdr_addr = ELFCORE_ADDR_ERR;
|
||||
|
||||
vmcore_report_crashed_release();
|
||||
|
||||
proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &vmcore_proc_ops);
|
||||
if (proc_vmcore)
|
||||
proc_vmcore->size = vmcore_size;
|
||||
|
||||
+4
-4
@@ -274,7 +274,7 @@ loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t si
|
||||
EXPORT_SYMBOL(fixed_size_llseek);
|
||||
|
||||
/**
|
||||
* no_seek_end_llseek - llseek implementation for fixed-sized devices
|
||||
* no_seek_end_llseek - llseek implementation for files without SEEK_END
|
||||
* @file: file structure to seek on
|
||||
* @offset: file offset to seek to
|
||||
* @whence: type of seek
|
||||
@@ -293,7 +293,7 @@ loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence)
|
||||
EXPORT_SYMBOL(no_seek_end_llseek);
|
||||
|
||||
/**
|
||||
* no_seek_end_llseek_size - llseek implementation for fixed-sized devices
|
||||
* no_seek_end_llseek_size - llseek implementation for files without SEEK_END
|
||||
* @file: file structure to seek on
|
||||
* @offset: file offset to seek to
|
||||
* @whence: type of seek
|
||||
@@ -1761,8 +1761,8 @@ EXPORT_SYMBOL(generic_write_checks_count);
|
||||
* Performs necessary checks before doing a write
|
||||
*
|
||||
* Can adjust writing position or amount of bytes to write.
|
||||
* Returns appropriate error code that caller should return or
|
||||
* zero in case that write should be allowed.
|
||||
* Returns the number of bytes that may be written on success (which
|
||||
* may be less than requested if truncated), or a negative error code.
|
||||
*/
|
||||
ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
|
||||
{
|
||||
|
||||
+49
-21
@@ -177,9 +177,9 @@ static const struct pipe_buf_operations user_page_pipe_buf_ops = {
|
||||
|
||||
static void wakeup_pipe_readers(struct pipe_inode_info *pipe)
|
||||
{
|
||||
smp_mb();
|
||||
if (waitqueue_active(&pipe->rd_wait))
|
||||
wake_up_interruptible(&pipe->rd_wait);
|
||||
if (wq_has_sleeper(&pipe->rd_wait))
|
||||
wake_up_interruptible_poll(&pipe->rd_wait,
|
||||
EPOLLIN | EPOLLRDNORM);
|
||||
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
|
||||
}
|
||||
|
||||
@@ -413,9 +413,9 @@ EXPORT_SYMBOL(nosteal_pipe_buf_ops);
|
||||
|
||||
static void wakeup_pipe_writers(struct pipe_inode_info *pipe)
|
||||
{
|
||||
smp_mb();
|
||||
if (waitqueue_active(&pipe->wr_wait))
|
||||
wake_up_interruptible(&pipe->wr_wait);
|
||||
if (wq_has_sleeper(&pipe->wr_wait))
|
||||
wake_up_interruptible_poll(&pipe->wr_wait,
|
||||
EPOLLOUT | EPOLLWRNORM);
|
||||
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
|
||||
}
|
||||
|
||||
@@ -1009,21 +1009,14 @@ ssize_t vfs_splice_read(struct file *in, loff_t *ppos,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vfs_splice_read);
|
||||
|
||||
/**
|
||||
* splice_direct_to_actor - splices data directly between two non-pipes
|
||||
* @in: file to splice from
|
||||
* @sd: actor information on where to splice to
|
||||
* @actor: handles the data splicing
|
||||
*
|
||||
* Description:
|
||||
* This is a special case helper to splice directly between two
|
||||
* points, without requiring an explicit pipe. Internally an allocated
|
||||
* pipe is cached in the process, and reused during the lifetime of
|
||||
* that process.
|
||||
*
|
||||
/*
|
||||
* This is a special case helper to splice directly between two
|
||||
* points, without requiring an explicit pipe. Internally an allocated
|
||||
* pipe is cached in the process, and reused during the lifetime of
|
||||
* that process.
|
||||
*/
|
||||
ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
|
||||
splice_direct_actor *actor)
|
||||
static ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
|
||||
splice_direct_actor *actor)
|
||||
{
|
||||
struct pipe_inode_info *pipe;
|
||||
ssize_t ret, bytes;
|
||||
@@ -1147,7 +1140,42 @@ out_release:
|
||||
|
||||
goto done;
|
||||
}
|
||||
EXPORT_SYMBOL(splice_direct_to_actor);
|
||||
|
||||
/**
|
||||
* vfs_splice_to_actor - call an actor on data read from a file
|
||||
* @in: file to read from
|
||||
* @pos: file offset
|
||||
* @count: maximum number of bytes to read
|
||||
* @actor: callback to process a pipe's worth of data
|
||||
* @private: private data passed to @actor
|
||||
*
|
||||
* Read up to @count worth of data from @in at @pos, and call @actor
|
||||
* when the hidden pipe used to buffer the data is full. Ensures the
|
||||
* read is allowed using rw_verify_area() and emits fsnotify access
|
||||
* events. @in must be seekable (FMODE_LSEEK).
|
||||
*
|
||||
* Return: The number of bytes spliced, or a negative errno.
|
||||
*/
|
||||
ssize_t vfs_splice_to_actor(struct file *in, loff_t pos, size_t count,
|
||||
splice_direct_actor *actor, void *private)
|
||||
{
|
||||
struct splice_desc sd = {
|
||||
.total_len = count,
|
||||
.pos = pos,
|
||||
.u.data = private,
|
||||
};
|
||||
ssize_t ret;
|
||||
|
||||
ret = rw_verify_area(READ, in, &sd.pos, sd.total_len);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = splice_direct_to_actor(in, &sd, actor);
|
||||
if (ret >= 0)
|
||||
fsnotify_access(in);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(vfs_splice_to_actor);
|
||||
|
||||
static int direct_splice_actor(struct pipe_inode_info *pipe,
|
||||
struct splice_desc *sd)
|
||||
|
||||
+1
-1
@@ -213,7 +213,7 @@ fail:
|
||||
static unsigned
|
||||
ufs_last_byte(struct inode *inode, unsigned long page_nr)
|
||||
{
|
||||
unsigned last_byte = inode->i_size;
|
||||
u64 last_byte = inode->i_size;
|
||||
|
||||
last_byte -= page_nr << PAGE_SHIFT;
|
||||
if (last_byte > PAGE_SIZE)
|
||||
|
||||
@@ -155,8 +155,6 @@ int dax_writeback_mapping_range(struct address_space *mapping,
|
||||
struct dax_device *dax_dev, struct writeback_control *wbc);
|
||||
int dax_folio_reset_order(struct folio *folio);
|
||||
|
||||
struct page *dax_layout_busy_page(struct address_space *mapping);
|
||||
struct page *dax_layout_busy_page_range(struct address_space *mapping, loff_t start, loff_t end);
|
||||
dax_entry_t dax_lock_folio(struct folio *folio);
|
||||
void dax_unlock_folio(struct folio *folio, dax_entry_t cookie);
|
||||
dax_entry_t dax_lock_mapping_entry(struct address_space *mapping,
|
||||
@@ -173,16 +171,6 @@ static inline int fs_dax_get(struct dax_device *dax_dev, void *holder,
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
static inline struct page *dax_layout_busy_page(struct address_space *mapping)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct page *dax_layout_busy_page_range(struct address_space *mapping, pgoff_t start, pgoff_t nr_pages)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int dax_writeback_mapping_range(struct address_space *mapping,
|
||||
struct dax_device *dax_dev, struct writeback_control *wbc)
|
||||
{
|
||||
|
||||
+1
-18
@@ -1436,7 +1436,7 @@ static inline void i_gid_write(struct inode *inode, gid_t gid)
|
||||
* @idmap: idmap of the mount the inode was found from
|
||||
* @inode: inode to map
|
||||
*
|
||||
* Return: whe inode's i_uid mapped down according to @idmap.
|
||||
* Return: the inode's i_uid mapped down according to @idmap.
|
||||
* If the inode's i_uid has no mapping INVALID_VFSUID is returned.
|
||||
*/
|
||||
static inline vfsuid_t i_uid_into_vfsuid(const struct mnt_idmap *idmap,
|
||||
@@ -3658,23 +3658,6 @@ extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,
|
||||
extern int generic_fadvise(struct file *file, loff_t offset, loff_t len,
|
||||
int advice);
|
||||
|
||||
static inline bool vfs_empty_path(int dfd, const char __user *path)
|
||||
{
|
||||
char c;
|
||||
|
||||
if (dfd < 0)
|
||||
return false;
|
||||
|
||||
/* We now allow NULL to be used for empty path. */
|
||||
if (!path)
|
||||
return true;
|
||||
|
||||
if (unlikely(get_user(c, path)))
|
||||
return false;
|
||||
|
||||
return !c;
|
||||
}
|
||||
|
||||
int generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter);
|
||||
|
||||
static inline bool extensible_ioctl_valid(unsigned int cmd_a,
|
||||
|
||||
@@ -79,8 +79,8 @@ ssize_t add_to_pipe(struct pipe_inode_info *pipe, struct pipe_buffer *buf);
|
||||
ssize_t vfs_splice_read(struct file *in, loff_t *ppos,
|
||||
struct pipe_inode_info *pipe, size_t len,
|
||||
unsigned int flags);
|
||||
ssize_t splice_direct_to_actor(struct file *file, struct splice_desc *sd,
|
||||
splice_direct_actor *actor);
|
||||
ssize_t vfs_splice_to_actor(struct file *file, loff_t pos, size_t count,
|
||||
splice_direct_actor *actor, void *private);
|
||||
ssize_t do_splice(struct file *in, loff_t *off_in, struct file *out,
|
||||
loff_t *off_out, size_t len, unsigned int flags);
|
||||
ssize_t do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
|
||||
|
||||
@@ -88,7 +88,7 @@ struct fstrim_range {
|
||||
* We include a length field because some filesystems (vfat) have an identifier
|
||||
* that we do want to expose as a UUID, but doesn't have the standard length.
|
||||
*
|
||||
* We use a fixed size buffer beacuse this interface will, by fiat, never
|
||||
* We use a fixed size buffer because this interface will, by fiat, never
|
||||
* support "UUIDs" longer than 16 bytes; we don't want to force all downstream
|
||||
* users to have to deal with that.
|
||||
*/
|
||||
|
||||
+6
-5
@@ -80,7 +80,7 @@ static __initdata struct hash {
|
||||
int ino, minor, major;
|
||||
umode_t mode;
|
||||
struct hash *next;
|
||||
char name[N_ALIGN(PATH_MAX)];
|
||||
char name[];
|
||||
} *head[32];
|
||||
static __initdata bool hardlink_seen;
|
||||
|
||||
@@ -92,7 +92,7 @@ static inline int hash(int major, int minor, int ino)
|
||||
}
|
||||
|
||||
static char __init *find_link(int major, int minor, int ino,
|
||||
umode_t mode, char *name)
|
||||
umode_t mode, const char *name, size_t nlen)
|
||||
{
|
||||
struct hash **p, *q;
|
||||
for (p = head + hash(major, minor, ino); *p; p = &(*p)->next) {
|
||||
@@ -106,14 +106,15 @@ static char __init *find_link(int major, int minor, int ino,
|
||||
continue;
|
||||
return (*p)->name;
|
||||
}
|
||||
q = kmalloc_obj(struct hash);
|
||||
|
||||
q = kmalloc_flex(struct hash, name, nlen);
|
||||
if (!q)
|
||||
panic_show_mem("can't allocate link hash entry");
|
||||
q->major = major;
|
||||
q->minor = minor;
|
||||
q->ino = ino;
|
||||
q->mode = mode;
|
||||
strscpy(q->name, name);
|
||||
strscpy(q->name, name, nlen);
|
||||
q->next = NULL;
|
||||
*p = q;
|
||||
hardlink_seen = true;
|
||||
@@ -355,7 +356,7 @@ static void __init clean_path(char *path, umode_t fmode)
|
||||
static int __init maybe_link(void)
|
||||
{
|
||||
if (nlink >= 2) {
|
||||
char *old = find_link(major, minor, ino, mode, collected);
|
||||
char *old = find_link(major, minor, ino, mode, collected, name_len);
|
||||
if (old) {
|
||||
clean_path(collected, 0);
|
||||
return (init_link(old, collected) < 0) ? -1 : 1;
|
||||
|
||||
@@ -38,6 +38,7 @@ TARGETS += filesystems/epoll
|
||||
TARGETS += filesystems/eventfd
|
||||
TARGETS += filesystems/failfs
|
||||
TARGETS += filesystems/fat
|
||||
TARGETS += filesystems/file_stressor
|
||||
TARGETS += filesystems/openat2
|
||||
TARGETS += filesystems/open_tree_ns
|
||||
TARGETS += filesystems/overlayfs
|
||||
|
||||
@@ -50,12 +50,12 @@ static void test_clone3_clear_sighand(void)
|
||||
* Check that CLONE_CLEAR_SIGHAND and CLONE_SIGHAND are mutually
|
||||
* exclusive.
|
||||
*/
|
||||
args.flags |= CLONE_CLEAR_SIGHAND | CLONE_SIGHAND;
|
||||
args.flags |= CLONE_VM | CLONE_CLEAR_SIGHAND | CLONE_SIGHAND;
|
||||
args.exit_signal = SIGCHLD;
|
||||
pid = sys_clone3(&args, sizeof(args));
|
||||
if (pid > 0)
|
||||
if (pid != -1 || errno != EINVAL)
|
||||
ksft_exit_fail_msg(
|
||||
"clone3(CLONE_CLEAR_SIGHAND | CLONE_SIGHAND) succeeded\n");
|
||||
"clone3(CLONE_CLEAR_SIGHAND | CLONE_SIGHAND) did not fail with EINVAL\n");
|
||||
|
||||
act.sa_handler = nop_handler;
|
||||
ret = sigemptyset(&act.sa_mask);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
dnotify_test
|
||||
devpts_pts
|
||||
fclog
|
||||
file_stressor
|
||||
anon_inode_test
|
||||
kernfs_test
|
||||
idmapped_tmpfile
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
CFLAGS += $(KHDR_INCLUDES)
|
||||
TEST_GEN_PROGS := devpts_pts file_stressor anon_inode_test kernfs_test fclog ustat_test rw_hint_test
|
||||
TEST_GEN_PROGS := devpts_pts anon_inode_test kernfs_test fclog ustat_test rw_hint_test
|
||||
TEST_GEN_PROGS += idmapped_tmpfile
|
||||
TEST_GEN_PROGS_EXTENDED := dnotify_test
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
file_stressor
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
CFLAGS += $(KHDR_INCLUDES)
|
||||
TEST_GEN_PROGS := file_stressor
|
||||
|
||||
include ../../lib.mk
|
||||
@@ -0,0 +1,3 @@
|
||||
# Timeout for file_stressor test
|
||||
# The test runs for 900 seconds (15 minutes) plus setup/teardown time
|
||||
timeout=1800
|
||||
@@ -0,0 +1,2 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
fscontext_ns_test
|
||||
@@ -91,6 +91,13 @@ FIXTURE_SETUP(idmapped_tmpfile)
|
||||
ASSERT_EQ(mkdir(self->dir, 0777), 0);
|
||||
/* World-writable so an unmapped caller still passes permission(). */
|
||||
ASSERT_EQ(chmod(self->dir, 0777), 0);
|
||||
/*
|
||||
* The directory itself must be inside the range the mount maps.
|
||||
* Left owned by 0 it has no mapping in the mount, and
|
||||
* inode_permission() then fails MAY_WRITE via HAS_UNMAPPED_ID()
|
||||
* before any of the tmpfile logic is reached, regardless of mode.
|
||||
*/
|
||||
ASSERT_EQ(chown(self->dir, MAP_HOST, MAP_HOST), 0);
|
||||
}
|
||||
|
||||
FIXTURE_TEARDOWN(idmapped_tmpfile)
|
||||
|
||||
@@ -26,12 +26,24 @@
|
||||
|
||||
TEST(kernfs_listxattr)
|
||||
{
|
||||
ssize_t len;
|
||||
int fd;
|
||||
|
||||
/* Read-only file that can never have any extended attributes set. */
|
||||
/* Read-only file that can never have any extended attributes set.
|
||||
* However, on systems with SELinux enabled, security.selinux xattr
|
||||
* may be present. Skip the content check if any xattrs are found.
|
||||
*/
|
||||
fd = open("/sys/kernel/warn_count", O_RDONLY | O_CLOEXEC);
|
||||
ASSERT_GE(fd, 0);
|
||||
ASSERT_EQ(flistxattr(fd, NULL, 0), 0);
|
||||
|
||||
len = flistxattr(fd, NULL, 0);
|
||||
ASSERT_GE(len, 0);
|
||||
|
||||
if (len > 0) {
|
||||
close(fd);
|
||||
SKIP(return, "xattrs present on /sys/kernel/warn_count, skipping xattr content check");
|
||||
}
|
||||
|
||||
EXPECT_EQ(close(fd), 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,16 @@
|
||||
* XXX: This is wrong on {mips, parisc, powerpc, sparc}.
|
||||
*/
|
||||
#undef O_LARGEFILE
|
||||
#ifdef __aarch64__
|
||||
#if defined(__aarch64__) || defined(__alpha__)
|
||||
#define O_LARGEFILE 0x20000
|
||||
#elif defined(__powerpc__) || defined(__ppc__)
|
||||
#define O_LARGEFILE 0x10000
|
||||
#elif defined(__sparc__)
|
||||
#define O_LARGEFILE 0x40000
|
||||
#elif defined(__mips__)
|
||||
#define O_LARGEFILE 0x2000
|
||||
#elif defined(__parisc__)
|
||||
#define O_LARGEFILE 0x800
|
||||
#else
|
||||
#define O_LARGEFILE 0x8000
|
||||
#endif
|
||||
|
||||
@@ -140,9 +140,12 @@ FIXTURE_SETUP(openat2_resolve)
|
||||
if (!openat2_supported)
|
||||
SKIP(return, "openat2(2) not supported");
|
||||
|
||||
/* Unshare and make /tmp a new directory. */
|
||||
/* Unshare and make the mount tree private. */
|
||||
ASSERT_EQ(unshare(CLONE_NEWNS), 0);
|
||||
ASSERT_EQ(mount("", "/tmp", "", MS_PRIVATE, ""), 0);
|
||||
ASSERT_EQ(mount("", "/", "", MS_PRIVATE | MS_REC, ""), 0);
|
||||
|
||||
/* Ensure /tmp is a mountpoint for RESOLVE_NO_XDEV test crossing into /tmp. */
|
||||
ASSERT_EQ(mount("/tmp", "/tmp", NULL, MS_BIND, NULL), 0);
|
||||
|
||||
/* Make the top-level directory. */
|
||||
ASSERT_NE(mkdtemp(dirname), NULL);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <linux/nsfs.h>
|
||||
#include <poll.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -20,6 +21,10 @@
|
||||
#include "../filesystems/utils.h"
|
||||
#include "wrappers.h"
|
||||
|
||||
#ifndef PIDFD_THREAD
|
||||
#define PIDFD_THREAD O_EXCL
|
||||
#endif
|
||||
|
||||
#ifndef FD_NSFS_ROOT
|
||||
#define FD_NSFS_ROOT -10003 /* Root of the nsfs filesystem */
|
||||
#endif
|
||||
@@ -2120,6 +2125,7 @@ TEST(ns_mixed_types_same_owner)
|
||||
/* Thread test helpers and structures */
|
||||
struct thread_ns_info {
|
||||
__u64 ns_id;
|
||||
int pidfd;
|
||||
int pipefd;
|
||||
int syncfd_read;
|
||||
int syncfd_write;
|
||||
@@ -2152,6 +2158,13 @@ static void *thread_create_namespace(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Open a pidfd so the main thread can later poll it to detect actual thread exit. */
|
||||
info->pidfd = syscall(__NR_pidfd_open, gettid(), PIDFD_THREAD);
|
||||
if (info->pidfd < 0) {
|
||||
info->exit_code = 6;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Send namespace ID to main thread */
|
||||
if (write(info->pipefd, &info->ns_id, sizeof(info->ns_id)) != sizeof(info->ns_id)) {
|
||||
info->exit_code = 4;
|
||||
@@ -2169,6 +2182,20 @@ static void *thread_create_namespace(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* pthread_join() returns once exit_mm() wakes the CLEARTID futex, before
|
||||
* exit_nsproxy_namespaces() drops the namespace reference. A pidfd becomes
|
||||
* readable only from exit_notify(), after that point.
|
||||
*/
|
||||
static int wait_thread_exited(int pidfd)
|
||||
{
|
||||
struct pollfd pfd = { .fd = pidfd, .events = POLLIN };
|
||||
int ret = poll(&pfd, 1, -1);
|
||||
|
||||
close(pidfd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that namespace becomes inactive after thread exits.
|
||||
* This verifies active reference counting works with threads, not just processes.
|
||||
@@ -2234,6 +2261,7 @@ TEST(thread_ns_inactive_after_exit)
|
||||
close(syncpipe[1]);
|
||||
|
||||
/* Wait for thread to exit */
|
||||
ASSERT_EQ(wait_thread_exited(info.pidfd), 1);
|
||||
ASSERT_EQ(pthread_join(thread, NULL), 0);
|
||||
close(pipefd[0]);
|
||||
close(pipefd[1]);
|
||||
@@ -2317,6 +2345,7 @@ TEST(thread_ns_fd_keeps_active)
|
||||
close(syncpipe[1]);
|
||||
|
||||
/* Wait for thread to exit */
|
||||
ASSERT_EQ(wait_thread_exited(info.pidfd), 1);
|
||||
pthread_join(thread, NULL);
|
||||
close(pipefd[0]);
|
||||
close(pipefd[1]);
|
||||
|
||||
@@ -168,7 +168,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
if (info.ppid != getppid()) {
|
||||
ksft_print_msg("ppid %d does not match ppid from ioctl %d\n",
|
||||
pid, info.pid);
|
||||
getppid(), info.ppid);
|
||||
goto on_error;
|
||||
}
|
||||
if (info.ruid != getuid()) {
|
||||
|
||||
Reference in New Issue
Block a user