osfs->os_namelen = HTON__u32(sfs->f_namelen);
}
+#if BITS_PER_LONG > 32
+#define statfs_max(val) val
+#else
+static inline long statfs_max(__u64 val)
+{
+ return ((long)val < val) ? (long)-1 : val;
+}
+#endif
+
+/*
+ * Note: since linux statfs is limited to a "long" for the statfs
+ * fields, we quickly overflow that. If we wanted, we could start
+ * playing games with the blocksize until the blocks count fit into
+ * a long. Note that it also appears that userspace interprets these
+ * 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)
{
if (osfs == NULL || sfs == NULL)
LBUG();
sfs->f_type = NTOH__u64(osfs->os_type);
- sfs->f_blocks = NTOH__u64(osfs->os_blocks);
- sfs->f_bfree = NTOH__u64(osfs->os_bfree);
- sfs->f_bavail = NTOH__u64(osfs->os_bavail);
- sfs->f_files = NTOH__u64(osfs->os_files);
- sfs->f_ffree = NTOH__u64(osfs->os_ffree);
+ 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);
}
CERROR("out of memory!\n");
RETURN(NULL);
}
-
+
memcpy(retval, value, strlen(value)+1);
CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
RETURN(retval);
GOTO(out_free, sb = NULL);
}
- obd = class_uuid2obd(mdc);
+ obd = class_uuid2obd(mdc);
if (!obd) {
CERROR("MDC %s: not setup or attached\n", mdc);
GOTO(out_free, sb = NULL);
CERROR("cannot connect to %s: rc = %d\n", mdc, err);
GOTO(out_free, sb = NULL);
}
-
+
#warning Peter: is this the right place to raise the connection level?
sbi2mdc(sbi)->cl_import.imp_connection->c_level = LUSTRE_CONN_FULL;
char *symlink_name = lli->lli_symlink_name;
if (md) {
- int size = sizeof(*md) +
+ int size = sizeof(*md) +
md->lmd_stripe_count * sizeof(struct lov_oinfo);
- OBD_FREE(md, size);
+ OBD_FREE(md, size);
lli->lli_smd = NULL;
}
if (symlink_name) {
if (rc)
CERROR("obd_statfs fails: rc = %d\n", rc);
else
- CDEBUG(D_SUPER, "statfs shows blocks %ld/%ld objects %ld/%ld\n",
+ CDEBUG(D_SUPER, "statfs shows blocks %lu/%lu objects %lu/%lu\n",
sfs->f_bavail, sfs->f_blocks, sfs->f_ffree,sfs->f_files);
/* temporary until mds_statfs returns statfs info for all OSTs */
CERROR("obd_statfs fails: rc = %d\n", rc);
GOTO(out, rc);
}
- CDEBUG(D_SUPER, "obd_statfs returns blocks %ld/%ld, "
- "objects %ld/%ld\n",
+ 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);
//if (body->valid & OBD_MD_FLEASIZE)
- if (md && md->md && md->md->lmd_stripe_count) {
+ if (md && md->md && md->md->lmd_stripe_count) {
struct lov_mds_md *smd = md->md;
int size;
if (md->md->lmd_easize != ll_stripe_mds_md_size(inode->i_sb)) {