From patchwork Mon Feb 27 02:50:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 61703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2210100wrd; Sun, 26 Feb 2023 19:23:42 -0800 (PST) X-Google-Smtp-Source: AK7set9PAadiqVDDUr8aZa+IkuR0aA2H7XEIBu/WSdRbmgUD/ul42Ffd63Qsh3peGpiN3ClOPCmh X-Received: by 2002:a05:6402:1299:b0:4ad:c0c6:980d with SMTP id w25-20020a056402129900b004adc0c6980dmr24479824edv.11.1677468221871; Sun, 26 Feb 2023 19:23:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677468221; cv=none; d=google.com; s=arc-20160816; b=cV+0jAOo55m/Xrwl7JczLRw5wmHCX71qbjI9flaS9mrCrY6IfEOPGzXC30f38iJYCX 1IghJOqm4U76X24Z9HC/B8bNgMqNLuM+UcAEq5ggWUkwhRJ49SwpeEBIe+Xo2LR74E3O x/s0a6NhqHgLNICaD4G3oaHhCbzKGEuDjOSzKwhLfiLoJvkIPVIxHam53yEc8Cy9AKmx 8y9ITGyQht6KQvrwvuR9lhWpfbV2YSMi+0dss6HDAEK5TzgglAhQh1UZLp2bM0RcuXA0 I6ovPM/aPQPNdozVOQ+zGaEdAg8c1R2QJFJzCaypbxFuFNXw55rQZWN40y2H7weLMZg7 qARw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c5gDKvjHxidcSyc7jC6hRM2muTQZ6HjOwvIbZ6edxuY=; b=T/sUgQysk5ocUyYLzNvNOBsr+Ck1edREYliACWsQTps9GJghpPfSRZ6tUITcjMhOoz VY1eaL419sFRJLR2DzqCFMuQIr/rtusqyBO/q+kYosybPnb9YiMi8ji8098dqukvpJF8 wmBTdsGPqYduY0qq60TTiwEs2bkPX50TindWaUWLU4ihEVzASQOctCyhaQ48kflF/mkq Kv28/eTQcfpvAVp8y10tCnNmROkPR15IzQxOivbAnxjl9pLcFTNi7fqj211WqL97HR95 voJ5o9/GG/YtSKg9qbrQlqbOket3mPG4/Qc/nWjqGUUcKKUDaYuRp4tC9aa5LK9AEuGe 7Ipw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OOyvJuhf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a056402060800b004aef418518asi6544626edv.282.2023.02.26.19.23.19; Sun, 26 Feb 2023 19:23:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OOyvJuhf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbjB0Cvi (ORCPT + 99 others); Sun, 26 Feb 2023 21:51:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbjB0Cvg (ORCPT ); Sun, 26 Feb 2023 21:51:36 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 684FBF77D; Sun, 26 Feb 2023 18:51:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 8002ECE0F01; Mon, 27 Feb 2023 02:51:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3FC8C433D2; Mon, 27 Feb 2023 02:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677466290; bh=U1ui6w8PIkWzsfrkm+P3XcVLn9Q3Wbpfqn5Hu03EgfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OOyvJuhfn8Us0FgqG4bX1fviPxIK71+A/n5AptgiRvnaoN1/U63qtKrm7XAKnzTAC rjAca0ZTvN9iHe1+YFWdOAdgWY4FlSdMv2PNG3VqU4q+e6JxURDXfDGO0IsxCcHvw7 uzq99OJEM8w8tqtrhGGwgyuOzBlIVlQ+WGau4U90qvVoKlDvqeU5n+bal2JK7yHTGU QFHkhzTdAZoZ3bar18mbGZbi3iSEgjX5TYDubHJXivQWYh4Tmn185xoPS9WLqm3AeN K2+fQjq0PigZcvWie1rhjCGWyHrIO6aSQl5PeQtEr3eOVPliDSbsNR1GifE+CebMqU qhHlh4KIPNgzw== From: Eric Van Hensbergen To: asmadeus@codewreck.org Cc: ericvh@gmail.com, ericvh@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux_oss@crudebyte.com, lucho@ionkov.net, rminnich@gmail.com, v9fs-developer@lists.sourceforge.net Subject: [PATCH v5 3/11] fs/9p: Consolidate file operations and add readahead and writeback Date: Mon, 27 Feb 2023 02:50:57 +0000 Message-Id: <20230227025056.24242-1-ericvh@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758127840330247865?= X-GMAIL-MSGID: =?utf-8?q?1758952918020439778?= We had 3 different sets of file operations across 2 different protocol variants differentiated by cache which really only changed 3 functions. But the real problem is that certain file modes, mount options, and other factors weren't being considered when we decided whether or not to use caches. This consolidates all the operations and switches to conditionals within a common set to decide whether or not to do different aspects of caching. Signed-off-by: Eric Van Hensbergen Reviewed-by: Dominique Martinet --- fs/9p/v9fs.c | 30 ++++------ fs/9p/v9fs.h | 2 + fs/9p/v9fs_vfs.h | 4 -- fs/9p/vfs_dir.c | 10 +++- fs/9p/vfs_file.c | 131 +++++++---------------------------------- fs/9p/vfs_inode.c | 41 +++++++------ fs/9p/vfs_inode_dotl.c | 28 +++++++-- 7 files changed, 84 insertions(+), 162 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 61a51b90600d..a46bf9121f11 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -39,8 +39,6 @@ enum { Opt_uname, Opt_remotename, Opt_cache, Opt_cachetag, /* Options that take no arguments */ Opt_nodevmap, - /* Cache options */ - Opt_cache_loose, Opt_fscache, Opt_mmap, /* Access options */ Opt_access, Opt_posixacl, /* Lock timeout option */ @@ -58,9 +56,6 @@ static const match_table_t tokens = { {Opt_remotename, "aname=%s"}, {Opt_nodevmap, "nodevmap"}, {Opt_cache, "cache=%s"}, - {Opt_cache_loose, "loose"}, - {Opt_fscache, "fscache"}, - {Opt_mmap, "mmap"}, {Opt_cachetag, "cachetag=%s"}, {Opt_access, "access=%s"}, {Opt_posixacl, "posixacl"}, @@ -69,10 +64,12 @@ static const match_table_t tokens = { }; static const char *const v9fs_cache_modes[nr__p9_cache_modes] = { - [CACHE_NONE] = "none", - [CACHE_MMAP] = "mmap", - [CACHE_LOOSE] = "loose", - [CACHE_FSCACHE] = "fscache", + [CACHE_NONE] = "none", + [CACHE_READAHEAD] = "readahead", + [CACHE_WRITEBACK] = "writeback", + [CACHE_MMAP] = "mmap", + [CACHE_LOOSE] = "loose", + [CACHE_FSCACHE] = "fscache", }; /* Interpret mount options for cache mode */ @@ -89,6 +86,12 @@ static int get_cache_mode(char *s) } else if (!strcmp(s, "mmap")) { version = CACHE_MMAP; p9_debug(P9_DEBUG_9P, "Cache mode: mmap\n"); + } else if (!strcmp(s, "writeback")) { + version = CACHE_WRITEBACK; + p9_debug(P9_DEBUG_9P, "Cache mode: writeback\n"); + } else if (!strcmp(s, "readahead")) { + version = CACHE_READAHEAD; + p9_debug(P9_DEBUG_9P, "Cache mode: readahead\n"); } else if (!strcmp(s, "none")) { version = CACHE_NONE; p9_debug(P9_DEBUG_9P, "Cache mode: none\n"); @@ -266,15 +269,6 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) case Opt_nodevmap: v9ses->nodev = 1; break; - case Opt_cache_loose: - v9ses->cache = CACHE_LOOSE; - break; - case Opt_fscache: - v9ses->cache = CACHE_FSCACHE; - break; - case Opt_mmap: - v9ses->cache = CACHE_MMAP; - break; case Opt_cachetag: #ifdef CONFIG_9P_FSCACHE kfree(v9ses->cachetag); diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 6acabc2e7dc9..972cfc681fe0 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -50,6 +50,8 @@ enum p9_session_flags { enum p9_cache_modes { CACHE_NONE, + CACHE_READAHEAD, + CACHE_WRITEBACK, CACHE_MMAP, CACHE_LOOSE, CACHE_FSCACHE, diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index bc417da7e9c1..cce87c9bdd8b 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h @@ -36,10 +36,6 @@ extern const struct file_operations v9fs_dir_operations; extern const struct file_operations v9fs_dir_operations_dotl; extern const struct dentry_operations v9fs_dentry_operations; extern const struct dentry_operations v9fs_cached_dentry_operations; -extern const struct file_operations v9fs_cached_file_operations; -extern const struct file_operations v9fs_cached_file_operations_dotl; -extern const struct file_operations v9fs_mmap_file_operations; -extern const struct file_operations v9fs_mmap_file_operations_dotl; extern struct kmem_cache *v9fs_inode_cache; struct inode *v9fs_alloc_inode(struct super_block *sb); diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index 3d74b04fe0de..289b58cb896e 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c @@ -197,9 +197,9 @@ static int v9fs_dir_readdir_dotl(struct file *file, struct dir_context *ctx) /** - * v9fs_dir_release - called on a close of a file or directory - * @inode: inode of the directory - * @filp: file pointer to a directory + * v9fs_dir_release - close a directory or a file + * @inode: inode of the directory or file + * @filp: file pointer to a directory or file * */ @@ -214,7 +214,11 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) fid = filp->private_data; p9_debug(P9_DEBUG_VFS, "inode: %p filp: %p fid: %d\n", inode, filp, fid ? fid->fid : -1); + if (fid) { + if ((S_ISREG(inode->i_mode)) && (filp->f_mode & FMODE_WRITE)) + retval = filemap_fdatawrite(inode->i_mapping); + spin_lock(&inode->i_lock); hlist_del(&fid->ilist); spin_unlock(&inode->i_lock); diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 3b6458846a0b..20e4bd299fc2 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -28,7 +28,6 @@ #include "fid.h" #include "cache.h" -static const struct vm_operations_struct v9fs_file_vm_ops; static const struct vm_operations_struct v9fs_mmap_file_vm_ops; /** @@ -73,7 +72,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) } mutex_lock(&v9inode->v_mutex); - if ((v9ses->cache) && !v9inode->writeback_fid && + if ((v9ses->cache >= CACHE_WRITEBACK) && !v9inode->writeback_fid && ((file->f_flags & O_ACCMODE) != O_RDONLY)) { /* * clone a fid and add it to writeback_fid @@ -367,10 +366,15 @@ v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct p9_fid *fid = iocb->ki_filp->private_data; int ret, err = 0; + struct inode *inode = file_inode(iocb->ki_filp); + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n", iov_iter_count(to), iocb->ki_pos); + if (v9ses->cache > CACHE_MMAP) + return generic_file_read_iter(iocb, to); + if (iocb->ki_filp->f_flags & O_NONBLOCK) ret = p9_client_read_once(fid, iocb->ki_pos, to, &err); else @@ -395,6 +399,11 @@ v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ssize_t retval; loff_t origin; int err = 0; + struct inode *inode = file_inode(iocb->ki_filp); + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + + if (v9ses->cache >= CACHE_WRITEBACK) + return generic_file_write_iter(iocb, from); retval = generic_write_checks(iocb, from); if (retval <= 0) @@ -477,25 +486,16 @@ static int v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma) { int retval; - - - retval = generic_file_mmap(filp, vma); - if (!retval) - vma->vm_ops = &v9fs_file_vm_ops; - - return retval; -} - -static int -v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma) -{ - int retval; - struct inode *inode; - struct v9fs_inode *v9inode; + struct inode *inode = file_inode(filp); + struct v9fs_inode *v9inode = V9FS_I(inode); + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); struct p9_fid *fid; - inode = file_inode(filp); - v9inode = V9FS_I(inode); + if (v9ses->cache < CACHE_MMAP) { + invalidate_inode_pages2(filp->f_mapping); + return generic_file_readonly_mmap(filp, vma); + } + mutex_lock(&v9inode->v_mutex); if (!v9inode->writeback_fid && (vma->vm_flags & VM_SHARED) && @@ -563,35 +563,6 @@ v9fs_vm_page_mkwrite(struct vm_fault *vmf) return VM_FAULT_NOPAGE; } -/** - * v9fs_mmap_file_read_iter - read from a file - * @iocb: The operation parameters - * @to: The buffer to read into - * - */ -static ssize_t -v9fs_mmap_file_read_iter(struct kiocb *iocb, struct iov_iter *to) -{ - /* TODO: Check if there are dirty pages */ - return v9fs_file_read_iter(iocb, to); -} - -/** - * v9fs_mmap_file_write_iter - write to a file - * @iocb: The operation parameters - * @from: The data to write - * - */ -static ssize_t -v9fs_mmap_file_write_iter(struct kiocb *iocb, struct iov_iter *from) -{ - /* - * TODO: invalidate mmaps on filp's inode between - * offset and offset+count - */ - return v9fs_file_write_iter(iocb, from); -} - static void v9fs_mmap_vm_close(struct vm_area_struct *vma) { struct inode *inode; @@ -614,13 +585,6 @@ static void v9fs_mmap_vm_close(struct vm_area_struct *vma) filemap_fdatawrite_wbc(inode->i_mapping, &wbc); } - -static const struct vm_operations_struct v9fs_file_vm_ops = { - .fault = filemap_fault, - .map_pages = filemap_map_pages, - .page_mkwrite = v9fs_vm_page_mkwrite, -}; - static const struct vm_operations_struct v9fs_mmap_file_vm_ops = { .close = v9fs_mmap_vm_close, .fault = filemap_fault, @@ -628,34 +592,6 @@ static const struct vm_operations_struct v9fs_mmap_file_vm_ops = { .page_mkwrite = v9fs_vm_page_mkwrite, }; - -const struct file_operations v9fs_cached_file_operations = { - .llseek = generic_file_llseek, - .read_iter = generic_file_read_iter, - .write_iter = generic_file_write_iter, - .open = v9fs_file_open, - .release = v9fs_dir_release, - .lock = v9fs_file_lock, - .mmap = v9fs_file_mmap, - .splice_read = generic_file_splice_read, - .splice_write = iter_file_splice_write, - .fsync = v9fs_file_fsync, -}; - -const struct file_operations v9fs_cached_file_operations_dotl = { - .llseek = generic_file_llseek, - .read_iter = generic_file_read_iter, - .write_iter = generic_file_write_iter, - .open = v9fs_file_open, - .release = v9fs_dir_release, - .lock = v9fs_file_lock_dotl, - .flock = v9fs_file_flock_dotl, - .mmap = v9fs_file_mmap, - .splice_read = generic_file_splice_read, - .splice_write = iter_file_splice_write, - .fsync = v9fs_file_fsync_dotl, -}; - const struct file_operations v9fs_file_operations = { .llseek = generic_file_llseek, .read_iter = v9fs_file_read_iter, @@ -677,34 +613,7 @@ const struct file_operations v9fs_file_operations_dotl = { .release = v9fs_dir_release, .lock = v9fs_file_lock_dotl, .flock = v9fs_file_flock_dotl, - .mmap = generic_file_readonly_mmap, - .splice_read = generic_file_splice_read, - .splice_write = iter_file_splice_write, - .fsync = v9fs_file_fsync_dotl, -}; - -const struct file_operations v9fs_mmap_file_operations = { - .llseek = generic_file_llseek, - .read_iter = v9fs_mmap_file_read_iter, - .write_iter = v9fs_mmap_file_write_iter, - .open = v9fs_file_open, - .release = v9fs_dir_release, - .lock = v9fs_file_lock, - .mmap = v9fs_mmap_file_mmap, - .splice_read = generic_file_splice_read, - .splice_write = iter_file_splice_write, - .fsync = v9fs_file_fsync, -}; - -const struct file_operations v9fs_mmap_file_operations_dotl = { - .llseek = generic_file_llseek, - .read_iter = v9fs_mmap_file_read_iter, - .write_iter = v9fs_mmap_file_write_iter, - .open = v9fs_file_open, - .release = v9fs_dir_release, - .lock = v9fs_file_lock_dotl, - .flock = v9fs_file_flock_dotl, - .mmap = v9fs_mmap_file_mmap, + .mmap = v9fs_file_mmap, .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync_dotl, diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 33e521c60e2c..61da885e4d40 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -287,24 +287,10 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses, case S_IFREG: if (v9fs_proto_dotl(v9ses)) { inode->i_op = &v9fs_file_inode_operations_dotl; - if (v9ses->cache == CACHE_LOOSE || - v9ses->cache == CACHE_FSCACHE) - inode->i_fop = - &v9fs_cached_file_operations_dotl; - else if (v9ses->cache == CACHE_MMAP) - inode->i_fop = &v9fs_mmap_file_operations_dotl; - else - inode->i_fop = &v9fs_file_operations_dotl; + inode->i_fop = &v9fs_file_operations_dotl; } else { inode->i_op = &v9fs_file_inode_operations; - if (v9ses->cache == CACHE_LOOSE || - v9ses->cache == CACHE_FSCACHE) - inode->i_fop = - &v9fs_cached_file_operations; - else if (v9ses->cache == CACHE_MMAP) - inode->i_fop = &v9fs_mmap_file_operations; - else - inode->i_fop = &v9fs_file_operations; + inode->i_fop = &v9fs_file_operations; } break; @@ -843,7 +829,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry, inode = d_inode(dentry); v9inode = V9FS_I(inode); mutex_lock(&v9inode->v_mutex); - if ((v9ses->cache) && !v9inode->writeback_fid && + if ((v9ses->cache >= CACHE_WRITEBACK) && !v9inode->writeback_fid && ((flags & O_ACCMODE) != O_RDONLY)) { /* * clone a fid and add it to writeback_fid @@ -1030,6 +1016,7 @@ v9fs_vfs_getattr(struct user_namespace *mnt_userns, const struct path *path, struct kstat *stat, u32 request_mask, unsigned int flags) { struct dentry *dentry = path->dentry; + struct inode *inode = d_inode(dentry); struct v9fs_session_info *v9ses; struct p9_fid *fid; struct p9_wstat *st; @@ -1039,6 +1026,12 @@ v9fs_vfs_getattr(struct user_namespace *mnt_userns, const struct path *path, if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { generic_fillattr(&init_user_ns, d_inode(dentry), stat); return 0; + } else if (v9ses->cache >= CACHE_WRITEBACK) { + if (S_ISREG(inode->i_mode)) { + int retval = filemap_fdatawrite(inode->i_mapping); + if (retval) + p9_debug(P9_DEBUG_ERROR, "flushing writeback during getattr returned %d\n", retval); + } } fid = v9fs_fid_lookup(dentry); if (IS_ERR(fid)) @@ -1115,8 +1108,11 @@ static int v9fs_vfs_setattr(struct user_namespace *mnt_userns, } /* Write all dirty data */ - if (d_is_reg(dentry)) - filemap_write_and_wait(inode->i_mapping); + if (d_is_reg(dentry)) { + retval = filemap_fdatawrite(inode->i_mapping); + if (retval) + p9_debug(P9_DEBUG_ERROR, "flushing writeback during setattr returned %d\n", retval); + } retval = p9_client_wstat(fid, &wstat); @@ -1127,9 +1123,12 @@ static int v9fs_vfs_setattr(struct user_namespace *mnt_userns, return retval; if ((iattr->ia_valid & ATTR_SIZE) && - iattr->ia_size != i_size_read(inode)) { + iattr->ia_size != i_size_read(inode)) { truncate_setsize(inode, iattr->ia_size); - fscache_resize_cookie(v9fs_inode_cookie(v9inode), iattr->ia_size); + if (v9ses->cache == CACHE_FSCACHE) + fscache_resize_cookie(v9fs_inode_cookie(v9inode), iattr->ia_size); + else + invalidate_mapping_pages(&inode->i_data, 0, -1); } v9fs_invalidate_inode_attr(inode); diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index bff37a312e64..84c1619e091d 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -458,6 +458,7 @@ v9fs_vfs_getattr_dotl(struct user_namespace *mnt_userns, struct dentry *dentry = path->dentry; struct v9fs_session_info *v9ses; struct p9_fid *fid; + struct inode *inode = d_inode(dentry); struct p9_stat_dotl *st; p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); @@ -465,6 +466,12 @@ v9fs_vfs_getattr_dotl(struct user_namespace *mnt_userns, if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { generic_fillattr(&init_user_ns, d_inode(dentry), stat); return 0; + } else if (v9ses->cache >= CACHE_WRITEBACK) { + if (S_ISREG(inode->i_mode)) { + int retval = filemap_fdatawrite(inode->i_mapping); + if (retval) + p9_debug(P9_DEBUG_ERROR, "flushing writeback during getattr returned %d\n", retval); + } } fid = v9fs_fid_lookup(dentry); if (IS_ERR(fid)) @@ -540,12 +547,14 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, struct dentry *dentry, struct iattr *iattr) { int retval, use_dentry = 0; + struct inode *inode = d_inode(dentry); + struct v9fs_inode *v9inode = V9FS_I(inode); + struct v9fs_session_info *v9ses; struct p9_fid *fid = NULL; struct p9_iattr_dotl p9attr = { .uid = INVALID_UID, .gid = INVALID_GID, }; - struct inode *inode = d_inode(dentry); p9_debug(P9_DEBUG_VFS, "\n"); @@ -553,6 +562,8 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, if (retval) return retval; + v9ses = v9fs_dentry2v9ses(dentry); + p9attr.valid = v9fs_mapped_iattr_valid(iattr->ia_valid); if (iattr->ia_valid & ATTR_MODE) p9attr.mode = iattr->ia_mode; @@ -583,8 +594,12 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, return PTR_ERR(fid); /* Write all dirty data */ - if (S_ISREG(inode->i_mode)) - filemap_write_and_wait(inode->i_mapping); + if (S_ISREG(inode->i_mode)) { + retval = filemap_fdatawrite(inode->i_mapping); + if (retval < 0) { + p9_debug(P9_DEBUG_ERROR, "Flushing file prior to setattr failed: %d\n", retval); + } + } retval = p9_client_setattr(fid, &p9attr); if (retval < 0) { @@ -593,9 +608,12 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, return retval; } - if ((iattr->ia_valid & ATTR_SIZE) && - iattr->ia_size != i_size_read(inode)) + if ((iattr->ia_valid & ATTR_SIZE) && iattr->ia_size != + i_size_read(inode)) { truncate_setsize(inode, iattr->ia_size); + if (v9ses->cache == CACHE_FSCACHE) + fscache_resize_cookie(v9fs_inode_cookie(v9inode), iattr->ia_size); + } v9fs_invalidate_inode_attr(inode); setattr_copy(&init_user_ns, inode, iattr); From patchwork Mon Feb 27 02:53:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 61698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2207041wrd; Sun, 26 Feb 2023 19:13:13 -0800 (PST) X-Google-Smtp-Source: AK7set8Hdd37/whXWKnIkwHCdEkHbzAsgmLuHKYXSTGwV2fVsFFd09myL+rcoTBwzJJppHj0LT5k X-Received: by 2002:a05:6402:799:b0:4ac:bf55:e943 with SMTP id d25-20020a056402079900b004acbf55e943mr24024735edy.34.1677467593725; Sun, 26 Feb 2023 19:13:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677467593; cv=none; d=google.com; s=arc-20160816; b=cRYdfaLAs5ielcA3S0gGeFnRKfYvFnv0nfabrfBFzlYZUxA+/TsWR8qoVJL8gMRFAP 2RT0Vhb4+z3AEwH3IdtmzosOgn7OBKxrdsXzj6qnTwRlVUJn0R07ASe7i7PrRuBGOAVx t4pEGQLmegUzppmLLdz5v4qhYVTOpTbV3duVLwhMjFIAKSCwG5ve/mabNHXW6Wgci5hu 8Cugt1X49V7CoGhcnHmZtXEIptWvz7KqlsufQi4gpCZM6WnU64qSmSsntIkTnAH4ukVD ulxYQlXsmmxg5uTMDjkY40JwYUoWJAR0fNWMFTXDQnlV52XpvHrE4vKe/zT2OKF5/tCK 83pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iSVXa9L7exrNB3Hl9alx2sV/+yExKgv5adL6+54Js1w=; b=KY26Gv4Y1lkzZZpJhFYOx0V20pPWkRkanlthzEfRML/vlgqD+5uvxKQMwwCywxFd5X eUq++Xb03KvsZ0wtsphQz+Z6tls2uBRVJndZx+bf5rdxxMvuPBjsWVL+H53+mNG/IUp6 NYywFitb8yEVFJIbQZgsJN+5r1Fx5tPOwNGUEbW+cI/JvHtL/hdebCvuiw9ClvMRlO9r 5eHRzEY8ruaE670InrJpn3JY1At/ePGjQTQ/TYiKGmNNjziISggp670+Y4dSUuqp9eX3 MgYLwmn52djvrxSWGnqsap+7d1/0sCJcJ4kzHEKEul88Wb7g4ESLo6z9BwQrjSgATRVq z3bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LaG5G6F2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o10-20020aa7d3ca000000b004ace0fce451si7160298edr.520.2023.02.26.19.12.51; Sun, 26 Feb 2023 19:13:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LaG5G6F2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229750AbjB0Cx2 (ORCPT + 99 others); Sun, 26 Feb 2023 21:53:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbjB0CxY (ORCPT ); Sun, 26 Feb 2023 21:53:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7562F8A4C; Sun, 26 Feb 2023 18:53:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 43854B80C9C; Mon, 27 Feb 2023 02:53:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DA18C4339B; Mon, 27 Feb 2023 02:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677466397; bh=N6ubcD/dFtgXOAPcau3LnF8+6AA0rIbK/jLGuc5X2sU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LaG5G6F2fXMMMgRcI9J0GHjh//KMsw0ThjpS17oq/9sRrfwKxfjVptX18TM6uL9tQ Bkgl+xKxyw1fD0kzFNE6TkZI3sl6bJFf5hDj8lyXy9eLe38v8LrppRGEjWVNlh5D4e M82zS6mLoZMyMb8T+w38Sqv1d80rQljJl4zLqCbUWw/R+tIpJHz3xkNtgwQPMaxaN0 Q3jed/4RyQfbkYvihDkplxb6+d9tiKuJFM4LmWWW9UNauA7zZ9WK2GSmK/5PkEgpPI SWmfe58Rt0BojGDziNDIocE+CbIItryhUO1/40q08wfp90XCU1lU3l5NNrnB735nSq 2HlVlqEf61/dg== From: Eric Van Hensbergen To: asmadeus@codewreck.org Cc: ericvh@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux_oss@crudebyte.com, lucho@ionkov.net, rminnich@gmail.com, v9fs-developer@lists.sourceforge.net Subject: [PATCH v5 7/11] 9p: Add additional debug flags and open modes Date: Mon, 27 Feb 2023 02:53:10 +0000 Message-Id: <20230227025310.24793-1-ericvh@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758127760454071759?= X-GMAIL-MSGID: =?utf-8?q?1758952259290714427?= Add some additional debug flags to assist with debugging cache changes. Also add some additional open modes so we can track cache state in fids more directly. Signed-off-by: Eric Van Hensbergen --- include/net/9p/9p.h | 6 ++++++ net/9p/client.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index 429adf6be29c..60cad0d200a4 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h @@ -42,6 +42,8 @@ enum p9_debug_flags { P9_DEBUG_PKT = (1<<10), P9_DEBUG_FSC = (1<<11), P9_DEBUG_VPKT = (1<<12), + P9_DEBUG_CACHE = (1<<13), + P9_DEBUG_MMAP = (1<<14), }; #ifdef CONFIG_NET_9P_DEBUG @@ -213,6 +215,10 @@ enum p9_open_mode_t { P9_ORCLOSE = 0x40, P9_OAPPEND = 0x80, P9_OEXCL = 0x1000, + P9L_MODE_MASK = 0x1FFF, /* don't send anything under this to server */ + P9L_DIRECT = 0x2000, /* cache disabled */ + P9L_NOWRITECACHE = 0x4000, /* no write caching */ + P9L_LOOSE = 0x8000, /* loose cache */ }; /** diff --git a/net/9p/client.c b/net/9p/client.c index 2adcb5e7b0e2..a3340268ec8d 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -1230,9 +1230,9 @@ int p9_client_open(struct p9_fid *fid, int mode) return -EINVAL; if (p9_is_proto_dotl(clnt)) - req = p9_client_rpc(clnt, P9_TLOPEN, "dd", fid->fid, mode); + req = p9_client_rpc(clnt, P9_TLOPEN, "dd", fid->fid, mode & P9L_MODE_MASK); else - req = p9_client_rpc(clnt, P9_TOPEN, "db", fid->fid, mode); + req = p9_client_rpc(clnt, P9_TOPEN, "db", fid->fid, mode & P9L_MODE_MASK); if (IS_ERR(req)) { err = PTR_ERR(req); goto error; @@ -1277,7 +1277,7 @@ int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags, return -EINVAL; req = p9_client_rpc(clnt, P9_TLCREATE, "dsddg", ofid->fid, name, flags, - mode, gid); + mode & P9L_MODE_MASK, gid); if (IS_ERR(req)) { err = PTR_ERR(req); goto error; @@ -1321,7 +1321,7 @@ int p9_client_fcreate(struct p9_fid *fid, const char *name, u32 perm, int mode, return -EINVAL; req = p9_client_rpc(clnt, P9_TCREATE, "dsdb?s", fid->fid, name, perm, - mode, extension); + mode & P9L_MODE_MASK, extension); if (IS_ERR(req)) { err = PTR_ERR(req); goto error; From patchwork Mon Feb 27 02:55:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 61700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2208136wrd; Sun, 26 Feb 2023 19:16:40 -0800 (PST) X-Google-Smtp-Source: AK7set+eMTRSuhtKRVKSdvaMXL17dQYEolB4bBH2ceSZ+l5Brg58r4G502wlE/zDrRFGU5mHvmdN X-Received: by 2002:a17:907:60d4:b0:8e1:cc38:6e78 with SMTP id hv20-20020a17090760d400b008e1cc386e78mr26901794ejc.39.1677467800679; Sun, 26 Feb 2023 19:16:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677467800; cv=none; d=google.com; s=arc-20160816; b=jFAj0Awn+zFJ0GCQWNMAwNSWfb1XL9/Y1q8FTjhM1JTiJF44edIlYS+P7fgYc1OmTy hd6mQHCw7rr1cKLvAG+Z2kBNizaEmjunkwlBIz+PjhGj2JAIQeUbKlpvCMmoVqRqi22E McJxwjkk1AHa4q7Zwlr/ugepLG/fnInKYuwi4ryRGKxjQ8agExwl5vRLR5G7bLxVfhJp ekvKD8OhM9cw4h0nhwx5ejaawU6l+LKwf6k8AajlbGjZPlEdLHL+25PlP8sw8T1bWepp I84/J8SUm6GwJAJyuiNEt9tjoq5nG7Dk/D/Lw8t4snzWPykJujXz8aNkVd2Yjhi54/QP u02g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JFWnkHxv5vpeRBctBvf2vJeGopdcuLG3WD+IaIQHYRw=; b=Vp8+4g5Ko2YWD3/xLtJ6iPs4xe5QRq25HFIxLhZ9eaWUTOKGhjFM/3lgSEFrXneV0R +zU2kOlk0jfrOf9ogXm+KxVevW1WDxUBArLzfQhNBRl3ptOyyQZ67ODLGzGxU10aWkdp sZso5rcRi+yN9DqyqjREBXpfj/JfO92Evl6KF/DMP/NoO17ZedClgfyr+I+7XSzaYXLz SAPV36cOUlsegEvr7wysmv5uZBShfyOGcemc3lP6/b8vGTx/Y3zann7Fmbq50i6M047N lhYXHbNDn4WdQyQQYxJMC9Syo0sv+7u/GXyY8jw5euoGkllgsEuFYk9FvGS1wZGoa/X9 7csg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V0x9Ma7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a1709062e9300b008b17b550d11si7210841eji.382.2023.02.26.19.16.18; Sun, 26 Feb 2023 19:16:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V0x9Ma7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229501AbjB0Czv (ORCPT + 99 others); Sun, 26 Feb 2023 21:55:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbjB0Czq (ORCPT ); Sun, 26 Feb 2023 21:55:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE33011EA5; Sun, 26 Feb 2023 18:55:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 68F1660D29; Mon, 27 Feb 2023 02:55:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1142C433EF; Mon, 27 Feb 2023 02:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677466536; bh=XzzzHWMtgZ6Vr9M2iDPwmlGp9yQezeqsE8i4VbxA0jM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V0x9Ma7B11r42JIm1XXV8r6kfdOc3DPv+fJH+QmRr0DghD469pKdjHRyjlCZCKJ3W kRBLnSBYHTMFJHC8S5LNMJWjCjRY/oUpEbdmM+sjqGlUIku+o8R7CVpazythVbkD4u 0Ndxd3wLmm9NHzXsa7cikgSJiodWXoyOvWkK6GpX1zMjFheJnwRlh4QIhX1X4x6Azz r1evSWhBkNuxtl1NMLTL3Thm4kuAD+4pKKRfEUwMAGZWK21iVlO+L5xua+MvxMgec3 u7qlsZ1WtCU4nYPDwpPdqIJbCsSvSq5TjaatYl9lEkDfXaMArt/RMX39Yc7OMzc3wh ukPBz2zRGVmtw== From: Eric Van Hensbergen To: asmadeus@codewreck.org Cc: ericvh@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux_oss@crudebyte.com, lucho@ionkov.net, rminnich@gmail.com, v9fs-developer@lists.sourceforge.net Subject: [PATCH v5 8/11] fs/9p: Add new mount modes Date: Mon, 27 Feb 2023 02:55:32 +0000 Message-Id: <20230227025532.25421-1-ericvh@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758127967956010874?= X-GMAIL-MSGID: =?utf-8?q?1758952476802609300?= Add some additional mount modes for cache management including specifying directio as a mount option and an option for ignore qid.version for determining whether or not a file is cacheable. Signed-off-by: Eric Van Hensbergen --- fs/9p/v9fs.c | 16 ++++++++++++++-- fs/9p/v9fs.h | 5 ++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index f8e952c013f9..43d3806150a9 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -38,7 +38,7 @@ enum { /* String options */ Opt_uname, Opt_remotename, Opt_cache, Opt_cachetag, /* Options that take no arguments */ - Opt_nodevmap, Opt_noxattr, + Opt_nodevmap, Opt_noxattr, Opt_directio, Opt_ignoreqv, /* Access options */ Opt_access, Opt_posixacl, /* Lock timeout option */ @@ -56,6 +56,8 @@ static const match_table_t tokens = { {Opt_remotename, "aname=%s"}, {Opt_nodevmap, "nodevmap"}, {Opt_noxattr, "noxattr"}, + {Opt_directio, "directio"}, + {Opt_ignoreqv, "ignoreqv"}, {Opt_cache, "cache=%s"}, {Opt_cachetag, "cachetag=%s"}, {Opt_access, "access=%s"}, @@ -125,7 +127,7 @@ int v9fs_show_options(struct seq_file *m, struct dentry *root) if (v9ses->nodev) seq_puts(m, ",nodevmap"); if (v9ses->cache) - seq_printf(m, ",%s", v9fs_cache_modes[v9ses->cache]); + seq_printf(m, ",cache=%s", v9fs_cache_modes[v9ses->cache]); #ifdef CONFIG_9P_FSCACHE if (v9ses->cachetag && v9ses->cache == CACHE_FSCACHE) seq_printf(m, ",cachetag=%s", v9ses->cachetag); @@ -147,6 +149,10 @@ int v9fs_show_options(struct seq_file *m, struct dentry *root) break; } + if (v9ses->flags & V9FS_IGNORE_QV) + seq_puts(m, ",ignoreqv"); + if (v9ses->flags & V9FS_DIRECT_IO) + seq_puts(m, ",directio"); if (v9ses->flags & V9FS_POSIX_ACL) seq_puts(m, ",posixacl"); @@ -276,6 +282,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) case Opt_noxattr: v9ses->flags |= V9FS_NO_XATTR; break; + case Opt_directio: + v9ses->flags |= V9FS_DIRECT_IO; + break; + case Opt_ignoreqv: + v9ses->flags |= V9FS_IGNORE_QV; + break; case Opt_cachetag: #ifdef CONFIG_9P_FSCACHE kfree(v9ses->cachetag); diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index a93327aed0d2..8e79b5b619af 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -37,7 +37,10 @@ enum p9_session_flags { V9FS_ACCESS_USER = 0x08, V9FS_ACCESS_CLIENT = 0x10, V9FS_POSIX_ACL = 0x20, - V9FS_NO_XATTR = 0x40 + V9FS_NO_XATTR = 0x40, + V9FS_IGNORE_QV = 0x80, /* ignore qid.version for cache hints */ + V9FS_DIRECT_IO = 0x100, + V9FS_SYNC = 0x200 }; /* possible values of ->cache */