From patchwork Thu Mar 18 20:16:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Garlick X-Patchwork-Id: 86802 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2IKGpQL025307 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 18 Mar 2010 20:17:28 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NsM94-0002br-1x; Thu, 18 Mar 2010 20:16:42 +0000 Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.122] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NsM92-0002be-HT for v9fs-developer@lists.sourceforge.net; Thu, 18 Mar 2010 20:16:40 +0000 Received-SPF: pass (sfi-mx-2.v28.ch3.sourceforge.com: domain of llnl.gov designates 128.115.41.83 as permitted sender) client-ip=128.115.41.83; envelope-from=garlick@llnl.gov; helo=smtp.llnl.gov; Received: from nspiron-3.llnl.gov ([128.115.41.83] helo=smtp.llnl.gov) by sfi-mx-2.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1NsM91-0006Z5-IX for v9fs-developer@lists.sourceforge.net; Thu, 18 Mar 2010 20:16:40 +0000 X-Attachments: None Received: from eris.llnl.gov ([134.9.2.84]) by smtp.llnl.gov with ESMTP; 18 Mar 2010 13:16:33 -0700 Received: from mrhankey.llnl.gov (mrhankey [192.168.1.135]) by eris.llnl.gov (Postfix) with ESMTP id C88B07C4A5; Thu, 18 Mar 2010 13:16:33 -0700 (PDT) Received: from mrhankey.llnl.gov (localhost.localdomain [127.0.0.1]) by mrhankey.llnl.gov (8.13.8/8.13.8) with ESMTP id o2IKGX7I000443; Thu, 18 Mar 2010 13:16:33 -0700 Received: (from garlick@localhost) by mrhankey.llnl.gov (8.13.8/8.13.8/Submit) id o2IKGXlM000442; Thu, 18 Mar 2010 13:16:33 -0700 From: Jim Garlick To: v9fs-developer@lists.sourceforge.net Date: Thu, 18 Mar 2010 13:16:32 -0700 Message-Id: <1268943393-420-2-git-send-email-garlick@llnl.gov> X-Mailer: git-send-email 1.5.4.5 In-Reply-To: <1268943393-420-1-git-send-email-garlick@llnl.gov> References: <1268943393-420-1-git-send-email-garlick@llnl.gov> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1NsM91-0006Z5-IX Cc: Jim Garlick Subject: [V9fs-developer] [PATCH 1/2] 9p: add 9P2000.L statfs operation X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 18 Mar 2010 20:17:28 +0000 (UTC) diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 69357c0..52600ee 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -208,12 +209,48 @@ v9fs_umount_begin(struct super_block *sb) v9fs_session_cancel(v9ses); } +static int v9fs_statfs(struct dentry *dentry, struct kstatfs *buf) +{ + struct v9fs_session_info *v9ses; + struct p9_fid *fid; + struct p9_rstatfs rs; + int res; + + fid = v9fs_fid_lookup(dentry); + if (IS_ERR(fid)) { + res = PTR_ERR(fid); + goto done; + } + + v9ses = v9fs_inode2v9ses(dentry->d_inode); + if (v9fs_proto_dotl(v9ses)) { + res = p9_client_statfs(fid, &rs); + if (res == 0) { + buf->f_type = rs.type; + buf->f_bsize = rs.bsize; + buf->f_blocks = rs.blocks; + buf->f_bfree = rs.bfree; + buf->f_bavail = rs.bavail; + buf->f_files = rs.files; + buf->f_ffree = rs.ffree; + buf->f_fsid.val[0] = rs.fsid & 0xFFFFFFFFUL; + buf->f_fsid.val[1] = (rs.fsid >> 32) & 0xFFFFFFFFUL; + buf->f_namelen = rs.namelen; + } + if (res != -ENOSYS) + goto done; + } + res = simple_statfs(dentry, buf); +done: + return res; +} + static const struct super_operations v9fs_super_ops = { #ifdef CONFIG_9P_FSCACHE .alloc_inode = v9fs_alloc_inode, .destroy_inode = v9fs_destroy_inode, #endif - .statfs = simple_statfs, + .statfs = v9fs_statfs, .clear_inode = v9fs_clear_inode, .show_options = generic_show_options, .umount_begin = v9fs_umount_begin, diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index a7fb548..59300dc 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h @@ -86,6 +86,8 @@ do { \ /** * enum p9_msg_t - 9P message types + * @P9_TSTATFS: file system status request + * @P9_RSTATFS: file system status response * @P9_TVERSION: version handshake request * @P9_RVERSION: version handshake response * @P9_TAUTH: request to establish authentication channel @@ -125,6 +127,8 @@ do { \ */ enum p9_msg_t { + P9_TSTATFS = 8, + P9_RSTATFS, P9_TVERSION = 100, P9_RVERSION, P9_TAUTH = 102, @@ -350,6 +354,22 @@ struct p9_wstat { }; /* Structures for Protocol Operations */ +struct p9_tstatfs { + u32 fid; +}; + +struct p9_rstatfs { + u32 type; + u32 bsize; + u64 blocks; + u64 bfree; + u64 bavail; + u64 files; + u64 ffree; + u64 fsid; + u32 namelen; +}; + struct p9_tversion { u32 msize; struct p9_str version; diff --git a/include/net/9p/client.h b/include/net/9p/client.h index f076dfa..44e2d8f 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h @@ -194,6 +194,7 @@ struct p9_fid { struct list_head dlist; /* list of all fids attached to a dentry */ }; +int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb); int p9_client_version(struct p9_client *); struct p9_client *p9_client_create(const char *dev_name, char *options); void p9_client_destroy(struct p9_client *clnt); diff --git a/net/9p/client.c b/net/9p/client.c index e3e5bf4..2851404 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -1348,3 +1348,42 @@ error: return err; } EXPORT_SYMBOL(p9_client_wstat); + +int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb) +{ + int err; + struct p9_req_t *req; + struct p9_client *clnt; + + err = 0; + clnt = fid->clnt; + + P9_DPRINTK(P9_DEBUG_9P, ">>> TSTATFS fid %d\n", fid->fid); + + req = p9_client_rpc(clnt, P9_TSTATFS, "d", fid->fid); + if (IS_ERR(req)) { + err = PTR_ERR(req); + goto error; + } + + err = p9pdu_readf(req->rc, clnt->proto_version, "ddqqqqqqd", &sb->type, + &sb->bsize, &sb->blocks, &sb->bfree, &sb->bavail, + &sb->files, &sb->ffree, &sb->fsid, &sb->namelen); + if (err) { + p9pdu_dump(1, req->rc); + p9_free_req(clnt, req); + goto error; + } + + P9_DPRINTK(P9_DEBUG_9P, "<<< RSTATFS fid %d type 0x%lx bsize %ld " + "blocks %llu bfree %llu bavail %llu files %llu ffree %llu " + "fsid %llu namelen %ld\n", + fid->fid, (long unsigned int)sb->type, (long int)sb->bsize, + sb->blocks, sb->bfree, sb->bavail, sb->files, sb->ffree, + sb->fsid, (long int)sb->namelen); + + p9_free_req(clnt, req); +error: + return err; +} +EXPORT_SYMBOL(p9_client_statfs);