From: nathan Date: Tue, 11 Oct 2005 00:47:41 +0000 (+0000) Subject: b=5831,6224 X-Git-Tag: v1_8_0_110~486^4~165 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=64b8c74ce14bace29aa744f1c340f9102e8ee285;p=fs%2Flustre-release.git b=5831,6224 Phil wanted to be sure these made it into mountconf. --- diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index f88243a..b8c467e 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -57,7 +57,10 @@ #include #include #include -#include +/* Hack for mkfs_lustre.c */ +#ifndef NO_SYS_VFS +# include +#endif #include #include @@ -309,11 +312,11 @@ static inline void spin_unlock_irqrestore(spinlock_t *a, unsigned long b) {} #ifndef min_t #define min_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) + ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) #endif #ifndef max_t #define max_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) + ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) #endif /* registering symbols */ @@ -646,7 +649,7 @@ static inline int schedule_timeout(signed long t) }) #define time_after(a, b) ((long)(b) - (long)(a) < 0) #define time_before(a, b) time_after(b,a) -#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) +#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0) struct timer_list { struct list_head tl_list; diff --git a/lustre/include/linux/lustre_disk.h b/lustre/include/linux/lustre_disk.h index 3cc46cf..8c956c9 100644 --- a/lustre/include/linux/lustre_disk.h +++ b/lustre/include/linux/lustre_disk.h @@ -124,7 +124,7 @@ struct mkfs_opts { char mo_device[128]; /* disk device name */ char mo_mkfsopts[128]; /* options to the backing-store mkfs */ char mo_loopdev[128]; /* in case a loop dev is needed */ - long mo_device_sz; + __u64 mo_device_sz; int mo_flags; /* Below here is required for writing mdt,ost,or client logs */ int mo_stripe_sz; diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 42a9b53..a787c61 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -36,6 +36,8 @@ #include #include +#define NO_SYS_VFS 1 +#include // for BLKGETSIZE64 #include #include #include "obdctl.h" @@ -251,35 +253,34 @@ int is_block(char* devname) return S_ISBLK(st.st_mode); } -/* Get the devsize from /proc/partitions with the major and minor number */ -int device_size_proc(char* device) +__u64 get_device_size(char* device) { - int major,minor,i,ret; - char *ma, *mi, *sz; - struct stat st; + int ret, fd; + __u64 size = 0; - ret = stat(device,&st); - if (ret != 0) { - fprintf(stderr,"can not stat %s\n",device); +#if 0 + sprintf(cmd, "sfdisk -s %s", device); + ret = run_command(cmd); + if (ret == 0) { + size = atoll(cmd_out[0]); + return (size); + } +#endif + /* bz5831 BLKGETSIZE64 */ + fd = open(device, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "cannot open %s: %s\n", device, strerror(errno)); exit(4); } - major = dev_major(st.st_rdev); - minor = dev_minor(st.st_rdev); - sprintf(cmd, "cat /proc/partitions"); - ret = run_command(cmd); - for (i = 0; i < 32; i++) { - if (strlen(cmd_out[i]) == 0) - break; - ma = strtok(cmd_out[i], " "); - mi = strtok(NULL, " "); - if ((major == atol(ma)) && (minor == atol(mi))) { - sz = strtok(NULL," "); - return atol(sz); - } + ret = ioctl(fd, BLKGETSIZE64, (void*)&size); + close(fd); + if (ret < 0) { + fprintf(stderr, "size ioctl failed: %s\n", strerror(errno)); + exit(4); } - - return 0; //FIXME : no entries in /proc/partitions + + return size; } void set_nid_pair(struct host_desc *nids, char *str) @@ -383,7 +384,7 @@ int loop_format(struct mkfs_opts *mop) loop_init(); - sprintf(cmd, "dd if=/dev/zero bs=1k count=0 seek=%ld of=%s", + sprintf(cmd, "dd if=/dev/zero bs=1k count=0 seek=%lld of=%s", mop->mo_device_sz, mop->mo_device); ret = run_command(cmd); if (ret != 0){ @@ -404,7 +405,7 @@ int make_lustre_backfs(struct mkfs_opts *mop) if (mop->mo_device_sz != 0) { if (mop->mo_device_sz < 8096){ fprintf(stderr, "size of filesystem must be larger " - "than 8MB, but is set to %ldKB\n", + "than 8MB, but is set to %lldKB\n", mop->mo_device_sz); return EINVAL; } @@ -413,17 +414,11 @@ int make_lustre_backfs(struct mkfs_opts *mop) if ((mop->mo_ldd.ldd_mount_type == LDD_MT_EXT3) || (mop->mo_ldd.ldd_mount_type == LDD_MT_LDISKFS)) { - long device_sz = mop->mo_device_sz; + __u64 device_sz = mop->mo_device_sz; /* we really need the size */ - if (device_sz == 0){ - sprintf(cmd, "sfdisk -s %s", mop->mo_device); - ret = run_command(cmd); - if (ret == 0) - device_sz = atol(cmd_out[0]); - else - device_sz = device_size_proc(mop->mo_device); - } + if (device_sz == 0) + device_sz = get_device_size(mop->mo_device); if (strstr(mop->mo_mkfsopts, "-J") == NULL) { /* Choose our own default journal size */ @@ -438,7 +433,7 @@ int make_lustre_backfs(struct mkfs_opts *mop) } } - /* Default is block size */ + /* Default bytes_per_inode is block size */ if (strstr(mop->mo_mkfsopts, "-i") == NULL) { long bytes_per_inode = 0; @@ -478,6 +473,12 @@ int make_lustre_backfs(struct mkfs_opts *mop) } + /* Enable hashed b-tree directory lookup in large dirs bz6224 */ + if (strstr(mop->mo_mkfsopts, "-O") == NULL) { + sprintf(buf, " -O dir_index"); + strcat(mop->mo_mkfsopts, buf); + } + sprintf(mkfs_cmd, "mkfs.ext2 -j -b 4096 -L %s ", mop->mo_ldd.ldd_svname); @@ -534,20 +535,6 @@ int make_lustre_backfs(struct mkfs_opts *mop) goto out; } - /* Enable hashed b-tree directory lookup in large dirs - FIXME MDT only? */ - if ((mop->mo_ldd.ldd_mount_type == LDD_MT_EXT3) || - (mop->mo_ldd.ldd_mount_type == LDD_MT_LDISKFS)) { - sprintf(cmd, "tune2fs -O dir_index %s", dev); - ret = run_command(cmd); - if (ret) { - fatal(); - fprintf(stderr,"Unable to enable htree: %s\n", - mop->mo_device); - goto out; - } - } - out: loop_cleanup(mop); return ret;