magic == LOV_MAGIC_FOREIGN;
}
-/* lov_do_div64(a, b) returns a % b, and a = a / b.
- * The 32-bit code is LOV-specific due to knowing about stripe limits in
- * order to reduce the divisor to a 32-bit number. If the divisor is
- * already a 32-bit value the compiler handles this directly. */
-#if BITS_PER_LONG == 64
-# define lov_do_div64(n, base) ({ \
- uint64_t __base = (base); \
- uint64_t __rem; \
- __rem = ((uint64_t)(n)) % __base; \
- (n) = ((uint64_t)(n)) / __base; \
- __rem; \
-})
-#elif BITS_PER_LONG == 32
-# define lov_do_div64(n, base) ({ \
- uint64_t __num = (n); \
- uint64_t __rem; \
- if ((sizeof(base) > 4) && (((base) & 0xffffffff00000000ULL) != 0)) { \
- int __remainder; \
- LASSERTF(!((base) & (LOV_MIN_STRIPE_SIZE - 1)), \
- "64 bit lov division %llu / %llu\n", \
- __num, (uint64_t)(base)); \
- __remainder = __num & (LOV_MIN_STRIPE_SIZE - 1); \
- __num >>= LOV_MIN_STRIPE_BITS; \
- __rem = do_div(__num, (base) >> LOV_MIN_STRIPE_BITS); \
- __rem <<= LOV_MIN_STRIPE_BITS; \
- __rem += __remainder; \
- } else { \
- __rem = do_div(__num, base); \
- } \
- (n) = __num; \
- __rem; \
-})
-#endif
-
#define pool_tgt_count(p) ((p)->pool_obds.op_count)
#define pool_tgt_array(p) ((p)->pool_obds.op_array)
#define pool_tgt_rw_sem(p) ((p)->pool_obds.op_rw_sem)
struct cl_attr *attr);
/* lov_offset.c */
-loff_t stripe_width(struct lov_stripe_md *lsm, unsigned int index);
+u64 stripe_width(struct lov_stripe_md *lsm, unsigned int index);
u64 lov_stripe_size(struct lov_stripe_md *lsm, int index,
u64 ost_size, int stripeno);
int lov_stripe_offset(struct lov_stripe_md *lsm, int index, loff_t lov_off,
int stripeno);
int lov_stripe_intersects(struct lov_stripe_md *lsm, int index, int stripeno,
struct lu_extent *ext, u64 *obd_start, u64 *obd_end);
-int lov_stripe_number(struct lov_stripe_md *lsm, int index, loff_t lov_off);
+int lov_stripe_number(struct lov_stripe_md *lsm, int index, u64 lov_off);
pgoff_t lov_stripe_pgoff(struct lov_stripe_md *lsm, int index,
pgoff_t stripe_index, int stripe);
/* need previous stripe involvement */
lio->lis_trunc_stripe_index[index] = prev;
} else {
- tr_start = ext.e_start;
- tr_start = lov_do_div64(tr_start,
- stripe_width(lsm, index));
+ div64_u64_rem(ext.e_start,
+ stripe_width(lsm, index),
+ &tr_start);
/* tr_start %= stripe_swidth */
if (tr_start == stripe * lsm->
lsm_entries[index]->
if (lse->lsme_stripe_count > 1) {
unsigned long ssize = lse->lsme_stripe_size;
- lov_do_div64(start, ssize);
+ start = div64_u64(start, ssize);
next = (start + 1) * ssize;
if (next <= start * ssize)
next = MAX_LFS_FILESIZE;
#include "lov_internal.h"
-loff_t stripe_width(struct lov_stripe_md *lsm, unsigned int index)
+u64 stripe_width(struct lov_stripe_md *lsm, unsigned int index)
{
struct lov_stripe_md_entry *entry = lsm->lsm_entries[index];
LASSERT(index < lsm->lsm_entry_count);
if (lsme_is_dom(entry))
- return (loff_t)entry->lsme_stripe_size;
+ return entry->lsme_stripe_size;
- return (loff_t)entry->lsme_stripe_size * entry->lsme_stripe_count;
+ return (u64)entry->lsme_stripe_size * entry->lsme_stripe_count;
}
/* compute object size given "stripeno" and the ost size */
u64 lov_stripe_size(struct lov_stripe_md *lsm, int index, u64 ost_size,
int stripeno)
{
- unsigned long ssize = lsm->lsm_entries[index]->lsme_stripe_size;
- unsigned long stripe_size;
- loff_t swidth;
- loff_t lov_size;
+ u32 ssize = lsm->lsm_entries[index]->lsme_stripe_size;
+ u32 stripe_size;
+ u64 swidth;
+ u64 lov_size;
ENTRY;
swidth = stripe_width(lsm, index);
- /* lov_do_div64(a, b) returns a % b, and a = a / b */
- stripe_size = lov_do_div64(ost_size, ssize);
+ ost_size = div_u64_rem(ost_size, ssize, &stripe_size);
if (stripe_size)
lov_size = ost_size * swidth + stripeno * ssize + stripe_size;
else
int stripeno, loff_t *obdoff)
{
unsigned long ssize = lsm->lsm_entries[index]->lsme_stripe_size;
- loff_t stripe_off;
- loff_t this_stripe;
- loff_t swidth;
+ u64 stripe_off, this_stripe, swidth;
int ret = 0;
if (lov_off == OBD_OBJECT_EOF) {
swidth = stripe_width(lsm, index);
- /* lov_do_div64(a, b) returns a % b, and a = a / b */
- stripe_off = lov_do_div64(lov_off, swidth);
+ lov_off = div64_u64_rem(lov_off, swidth, &stripe_off);
- this_stripe = (loff_t)stripeno * ssize;
+ this_stripe = (u64)stripeno * ssize;
if (stripe_off < this_stripe) {
stripe_off = 0;
ret = -1;
int stripeno)
{
unsigned long ssize = lsm->lsm_entries[index]->lsme_stripe_size;
- loff_t stripe_off;
- loff_t this_stripe;
- loff_t swidth;
+ u64 stripe_off;
+ u64 this_stripe;
+ u64 swidth;
if (file_size == OBD_OBJECT_EOF)
return OBD_OBJECT_EOF;
swidth = stripe_width(lsm, index);
- /* lov_do_div64(a, b) returns a % b, and a = a / b */
- stripe_off = lov_do_div64(file_size, swidth);
+ file_size = div64_u64_rem(file_size, swidth, &stripe_off);
- this_stripe = (loff_t)stripeno * ssize;
+ this_stripe = (u64)stripeno * ssize;
if (stripe_off < this_stripe) {
/* Move to end of previous stripe, or zero */
if (file_size > 0) {
}
/* compute which stripe number "lov_off" will be written into */
-int lov_stripe_number(struct lov_stripe_md *lsm, int index, loff_t lov_off)
+int lov_stripe_number(struct lov_stripe_md *lsm, int index, u64 lov_off)
{
unsigned long ssize = lsm->lsm_entries[index]->lsme_stripe_size;
- loff_t stripe_off;
- loff_t swidth;
+ u64 stripe_off;
+ u64 swidth;
swidth = stripe_width(lsm, index);
- stripe_off = lov_do_div64(lov_off, swidth);
+ lov_off = div64_u64_rem(lov_off, swidth, &stripe_off);
/* Puts stripe_off/ssize result into stripe_off */
- lov_do_div64(stripe_off, ssize);
+ stripe_off = div_u64(stripe_off, ssize);
- return stripe_off;
+ return (int) stripe_off;
}
__u32 expected_stripes = lov_get_stripe_count(&obd->u.lov,
LOV_MAGIC, 0);
if (osfs->os_files != U64_MAX)
- lov_do_div64(osfs->os_files, expected_stripes);
+ do_div(osfs->os_files, expected_stripes);
if (osfs->os_ffree != U64_MAX)
- lov_do_div64(osfs->os_ffree, expected_stripes);
+ do_div(osfs->os_ffree, expected_stripes);
spin_lock(&obd->obd_osfs_lock);
memcpy(&obd->obd_osfs, osfs, sizeof(*osfs));
}
run_test 4 "run llverfs on lustre filesystem"
+test_5() {
+ # Setup the Lustre filesystem.
+ log "setup the lustre filesystem"
+ REFORMAT="yes" check_and_setup_lustre
+
+ $LFS setstripe -C 1024 $MOUNT/$tfile || error "creating $MOUNT/$tfile"
+ stack_trap "rm -f $MOUNT/$tfile"
+
+ # Create a 32TB size file and write 4K every GB offset
+ log "run_llverdev $MOUNT/$tfile -p -c 4096 -s 32T"
+ run_llverdev $MOUNT/$tfile -o 18T -s 33554432 ||
+ error "llverdev failed with rc=$?"
+ stopall
+}
+run_test 5 "run llverdev on lustre filesystem"
+
complete_test $SECONDS
$LARGE_LUN_RESTORE_MOUNT && setupall
check_and_cleanup_lustre