From: adilger Date: Fri, 6 Sep 2002 09:46:45 +0000 (+0000) Subject: At least acknowledge that statfs wraps at 16TB filesystems. We could X-Git-Tag: 0.5.7~62 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=fdc7bce3dbbb4b16700f2b6ef001c5c42f34cf66;p=fs%2Flustre-release.git At least acknowledge that statfs wraps at 16TB filesystems. We could probably increase blocksize until the block counts fit into a long, maybe up to some limit (64kB = 256TB max, or 64kB x stripecount = much larger). --- diff --git a/lustre/lib/ll_pack.c b/lustre/lib/ll_pack.c index 44152f2..599818e 100644 --- a/lustre/lib/ll_pack.c +++ b/lustre/lib/ll_pack.c @@ -42,17 +42,34 @@ void obd_statfs_pack(struct obd_statfs *osfs, struct statfs *sfs) 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); } diff --git a/lustre/llite/super.c b/lustre/llite/super.c index 69d9c42..687b199 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -46,7 +46,7 @@ static char *ll_read_opt(const char *opt, char *data) 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); @@ -120,7 +120,7 @@ static struct super_block * ll_read_super(struct super_block *sb, 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); @@ -131,7 +131,7 @@ static struct super_block * ll_read_super(struct super_block *sb, 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; @@ -244,9 +244,9 @@ static void ll_clear_inode(struct inode *inode) 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) { @@ -365,7 +365,7 @@ static int ll_statfs(struct super_block *sb, struct statfs *sfs) 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 */ @@ -377,8 +377,8 @@ static int ll_statfs(struct super_block *sb, struct statfs *sfs) 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); @@ -436,7 +436,7 @@ static void ll_read_inode2(struct inode *inode, void *opaque) //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)) {