struct obd_statfs;
struct statfs;
-void obd_statfs_pack(struct obd_statfs *osfs, struct statfs *sfs);
-void obd_statfs_unpack(struct obd_statfs *osfs, struct statfs *sfs);
+void statfs_pack(struct obd_statfs *osfs, struct statfs *sfs);
+void statfs_unpack(struct statfs *sfs, struct obd_statfs *osfs);
+void obd_statfs_pack(struct obd_statfs *tgt, struct obd_statfs *src);
+static inline void
+obd_statfs_unpack(struct obd_statfs *tgt, struct obd_statfs *src)
+{
+ obd_statfs_pack(tgt, src);
+}
#include <linux/portals_lib.h>
int mdc_getattr(struct lustre_handle *conn,
obd_id ino, int type, unsigned long valid, size_t ea_size,
struct ptlrpc_request **request);
-int mdc_statfs(struct lustre_handle *conn,
- struct statfs *sfs, struct ptlrpc_request **request);
+int mdc_statfs(struct lustre_handle *conn, struct obd_statfs *osfs,
+ struct ptlrpc_request **request);
int mdc_setattr(struct lustre_handle *conn,
struct inode *, struct iattr *iattr, struct ptlrpc_request **);
int mdc_open(struct lustre_handle *conn, obd_id ino, int type, int flags,
int (*o_disconnect)(struct lustre_handle *conn);
- int (*o_statfs)(struct lustre_handle *conn, struct statfs *statfs);
+ int (*o_statfs)(struct lustre_handle *conn, struct obd_statfs *osfs);
int (*o_preallocate)(struct lustre_handle *, obd_count *req,
obd_id *ids);
int (*o_create)(struct lustre_handle *conn, struct obdo *oa,
RETURN(rc);
}
-static inline int obd_statfs(struct lustre_handle *conn, struct statfs *buf)
+static inline int obd_statfs(struct lustre_handle *conn,struct obd_statfs *osfs)
{
int rc;
struct obd_export *export;
OBD_CHECK_SETUP(conn, export);
OBD_CHECK_OP(export->exp_obd,statfs);
- rc = OBP(export->exp_obd, statfs)(conn, buf);
+ rc = OBP(export->exp_obd, statfs)(conn, osfs);
RETURN(rc);
}
#include <linux/lustre_net.h>
#include <linux/obd_support.h>
-void obd_statfs_pack(struct obd_statfs *osfs, struct statfs *sfs)
+void obd_statfs_pack(struct obd_statfs *tgt, struct obd_statfs *src)
{
- if (osfs == NULL || sfs == NULL)
- LBUG();
+ tgt->os_type = HTON__u64(src->os_type);
+ tgt->os_blocks = HTON__u64(src->os_blocks);
+ tgt->os_bfree = HTON__u64(src->os_bfree);
+ tgt->os_bavail = HTON__u64(src->os_bavail);
+ tgt->os_files = HTON__u64(src->os_files);
+ tgt->os_ffree = HTON__u64(src->os_ffree);
+ tgt->os_bsize = HTON__u32(src->os_bsize);
+ tgt->os_namelen = HTON__u32(src->os_namelen);
+}
+
+#define obd_statfs_unpack(tgt, src) obd_statfs_pack(tgt, src)
- osfs->os_type = HTON__u64(sfs->f_type);
- osfs->os_blocks = HTON__u64(sfs->f_blocks);
- osfs->os_bfree = HTON__u64(sfs->f_bfree);
- osfs->os_bavail = HTON__u64(sfs->f_bavail);
- osfs->os_files = HTON__u64(sfs->f_files);
- osfs->os_ffree = HTON__u64(sfs->f_ffree);
- osfs->os_bsize = HTON__u32(sfs->f_bsize);
- osfs->os_namelen = HTON__u32(sfs->f_namelen);
+void statfs_pack(struct obd_statfs *osfs, struct statfs *sfs)
+{
+ osfs->os_type = sfs->f_type;
+ osfs->os_blocks = sfs->f_blocks;
+ osfs->os_bfree = sfs->f_bfree;
+ osfs->os_bavail = sfs->f_bavail;
+ osfs->os_files = sfs->f_files;
+ osfs->os_ffree = sfs->f_ffree;
+ osfs->os_bsize = sfs->f_bsize;
+ osfs->os_namelen = sfs->f_namelen;
}
#if BITS_PER_LONG > 32
* fields as an unsigned long, which is helps us a bit, and it also
* appears to do 64-bit math for at least some of the computations.
*/
-void obd_statfs_unpack(struct obd_statfs *osfs, struct statfs *sfs)
+void statfs_unpack(struct statfs *sfs, struct obd_statfs *osfs)
{
- if (osfs == NULL || sfs == NULL)
- LBUG();
-
- sfs->f_type = NTOH__u64(osfs->os_type);
- sfs->f_blocks = statfs_max(NTOH__u64(osfs->os_blocks));
- sfs->f_bfree = statfs_max(NTOH__u64(osfs->os_bfree));
- sfs->f_bavail = statfs_max(NTOH__u64(osfs->os_bavail));
- sfs->f_files = statfs_max(NTOH__u64(osfs->os_files));
- sfs->f_ffree = statfs_max(NTOH__u64(osfs->os_ffree));
- sfs->f_bsize = NTOH__u32(osfs->os_bsize);
- sfs->f_namelen = NTOH__u32(osfs->os_namelen);
+ sfs->f_type = osfs->os_type;
+ sfs->f_blocks = statfs_max(osfs->os_blocks);
+ sfs->f_bfree = statfs_max(osfs->os_bfree);
+ sfs->f_bavail = statfs_max(osfs->os_bavail);
+ sfs->f_files = statfs_max(osfs->os_files);
+ sfs->f_ffree = statfs_max(osfs->os_ffree);
+ sfs->f_bsize = osfs->os_bsize;
+ sfs->f_namelen = osfs->os_namelen;
}
char *mdc = NULL;
int err;
struct ll_fid rootfid;
- struct statfs sfs;
+ struct obd_statfs osfs;
__u64 last_committed;
__u64 last_xid;
struct ptlrpc_request *request = NULL;
CDEBUG(D_SUPER, "rootfid %Ld\n", (unsigned long long)rootfid.id);
sbi->ll_rootino = rootfid.id;
- memset(&sfs, 0, sizeof(sfs));
+ memset(&osfs, 0, sizeof(osfs));
request = NULL;
- err = mdc_statfs(&sbi->ll_mdc_conn, &sfs, &request);
+ err = mdc_statfs(&sbi->ll_mdc_conn, &osfs, &request);
ptlrpc_req_finished(request);
- sb->s_blocksize = sfs.f_bsize;
- sb->s_blocksize_bits = log2(sfs.f_bsize);
+ sb->s_blocksize = osfs.os_bsize;
+ sb->s_blocksize_bits = log2(osfs.os_bsize);
sb->s_magic = LL_SUPER_MAGIC;
- sb->s_maxbytes = (1ULL << (32 + 9)) - sfs.f_bsize;
+ sb->s_maxbytes = (1ULL << (32 + 9)) - osfs.os_bsize;
sb->s_op = &ll_super_operations;
{
struct ptlrpc_request *request = NULL;
struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct obd_statfs osfs;
int rc;
ENTRY;
memset(sfs, 0, sizeof(*sfs));
- rc = mdc_statfs(&sbi->ll_mdc_conn, sfs, &request);
+ rc = mdc_statfs(&sbi->ll_mdc_conn, &osfs, &request);
+ statfs_unpack(sfs, &osfs);
ptlrpc_req_finished(request);
if (rc)
- CERROR("obd_statfs fails: rc = %d\n", rc);
+ CERROR("mdc_statfs fails: rc = %d\n", rc);
else
- CDEBUG(D_SUPER, "statfs shows blocks %lu/%lu objects %lu/%lu\n",
- sfs->f_bavail, sfs->f_blocks, sfs->f_ffree,sfs->f_files);
+ CDEBUG(D_SUPER, "mdc_statfs shows blocks "LPU64"/"LPU64
+ " objects "LPU64"/"LPU64"\n",
+ osfs.os_bavail, osfs.os_blocks,
+ osfs.os_ffree, osfs.os_files);
/* temporary until mds_statfs returns statfs info for all OSTs */
if (!rc) {
struct statfs obd_sfs;
- rc = obd_statfs(&sbi->ll_osc_conn, &obd_sfs);
+ rc = obd_statfs(&sbi->ll_osc_conn, &osfs);
+ statfs_unpack(&obd_sfs, &osfs);
if (rc) {
CERROR("obd_statfs fails: rc = %d\n", rc);
GOTO(out, rc);
}
- CDEBUG(D_SUPER, "obd_statfs returns blocks %lu/%lu, "
- "objects %lu/%lu\n",
- obd_sfs.f_bavail, obd_sfs.f_blocks,
- obd_sfs.f_ffree, obd_sfs.f_files);
+ CDEBUG(D_SUPER, "obd_statfs shows blocks "LPU64"/"LPU64
+ " objects "LPU64"/"LPU64"\n",
+ osfs.os_bavail, osfs.os_blocks,
+ osfs.os_ffree, osfs.os_files);
sfs->f_bfree = obd_sfs.f_bfree;
sfs->f_bavail = obd_sfs.f_bavail;
RETURN(rc);
}
-static int lov_statfs(struct lustre_handle *conn, struct statfs *sfs)
+static int lov_statfs(struct lustre_handle *conn, struct obd_statfs *osfs)
{
struct obd_export *export = class_conn2export(conn);
struct lov_obd *lov;
- struct statfs lov_sfs;
+ struct obd_statfs lov_sfs;
int set = 0;
int rc = 0;
int i;
continue; /* XXX or break? - probably OK to continue */
}
if (!set) {
- memcpy(sfs, &lov_sfs, sizeof(lov_sfs));
+ memcpy(osfs, &lov_sfs, sizeof(lov_sfs));
set = 1;
} else {
- sfs->f_bfree += lov_sfs.f_bfree;
- sfs->f_bavail += lov_sfs.f_bavail;
- sfs->f_blocks += lov_sfs.f_blocks;
+ osfs->os_bfree += lov_sfs.os_bfree;
+ osfs->os_bavail += lov_sfs.os_bavail;
+ osfs->os_blocks += lov_sfs.os_blocks;
/* XXX not sure about this one - depends on policy.
* - could be minimum if we always stripe on all OBDs
* (but that would be wrong for any other policy,
return rc;
}
-int mdc_statfs(struct lustre_handle *conn, struct statfs *sfs,
+int mdc_statfs(struct lustre_handle *conn, struct obd_statfs *osfs,
struct ptlrpc_request **request)
{
- struct obd_statfs *osfs;
struct ptlrpc_request *req;
int rc, size = sizeof(*osfs);
ENTRY;
if (rc)
GOTO(out, rc);
- osfs = lustre_msg_buf(req->rq_repmsg, 0);
- obd_statfs_unpack(osfs, sfs);
+ obd_statfs_unpack(osfs, lustre_msg_buf(req->rq_repmsg, 0));
EXIT;
out:
}
osfs = lustre_msg_buf(req->rq_repmsg, 0);
memset(osfs, 0, size);
- obd_statfs_pack(osfs, &sfs);
+ statfs_pack(osfs, &sfs);
+ obd_statfs_pack(osfs, osfs);
out:
req->rq_status = rc;
modulefs_DATA = obdfilter.o
EXTRA_PROGRAMS = obdfilter
-LINX=simple.c
+LINX=simple.c ll_pack.c
+ll_pack.c:
+ test -e ll_pack.c || ln -sf $(top_srcdir)/lib/ll_pack.c
+
simple.c:
test -e simple.c || ln -sf $(top_srcdir)/lib/simple.c
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * linux/fs/filter/filter.c
+ * linux/fs/obdfilter/filter.c
*
- * Copyright (C) 2001 Cluster File Systems, Inc.
+ * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
*
* This code is issued under the GNU General Public License.
* See the file COPYING in this distribution
*
* by Peter Braam <braam@clusterfs.com>
+ * and Andreas Dilger <adilger@clusterfs.com>
*/
#define EXPORT_SYMTAB
RETURN(rc);
}
-static int filter_statfs(struct lustre_handle *conn, struct statfs *statfs)
+static int filter_statfs(struct lustre_handle *conn, struct obd_statfs *osfs)
{
struct obd_device *obd = class_conn2obd(conn);
+ struct statfs sfs;
+ int rc;
ENTRY;
- RETURN(vfs_statfs(obd->u.filter.fo_sb, statfs));
+ rc = vfs_statfs(obd->u.filter.fo_sb, &sfs);
+ if (!rc)
+ statfs_pack(osfs, &sfs);
+
+ return rc;
}
static int filter_get_info(struct lustre_handle *conn, obd_count keylen,
RETURN(0);
}
-static int osc_statfs(struct lustre_handle *conn, struct statfs *sfs)
+static int osc_statfs(struct lustre_handle *conn, struct obd_statfs *osfs)
{
struct ptlrpc_request *request;
- struct obd_statfs *osfs;
int rc, size = sizeof(*osfs);
ENTRY;
GOTO(out, rc);
}
- osfs = lustre_msg_buf(request->rq_repmsg, 0);
- obd_statfs_unpack(osfs, sfs);
+ obd_statfs_unpack(osfs, lustre_msg_buf(request->rq_repmsg, 0));
EXIT;
out:
{
struct lustre_handle *conn = (struct lustre_handle *)req->rq_reqmsg;
struct obd_statfs *osfs;
- struct statfs sfs;
int rc, size = sizeof(*osfs);
ENTRY;
- rc = obd_statfs(conn, &sfs);
- if (rc) {
- CERROR("ost: statfs failed: rc %d\n", rc);
- req->rq_status = rc;
- RETURN(rc);
- }
-
rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
if (rc)
RETURN(rc);
osfs = lustre_msg_buf(req->rq_repmsg, 0);
memset(osfs, 0, size);
- obd_statfs_pack(osfs, &sfs);
+
+ rc = obd_statfs(conn, osfs);
+ if (rc) {
+ CERROR("ost: statfs failed: rc %d\n", rc);
+ req->rq_status = rc;
+ RETURN(rc);
+ }
+ obd_statfs_pack(osfs, osfs);
+
RETURN(0);
}