Define the OBIF|IDIF_MAX_OID macros to 1ULL << OBIF|IDIF_MAX_BITS - 1
Clean up the callers and remove OBIF|IDIF_OID_MASK which are not used.
Test-Parameters: trivial
Change-Id: I9a679b930c73da5904b2eb4c74f785fc1d27a8a0
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/45659
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sergey Cheremencev <scherementsev@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
static inline int ostid_set_id(struct ost_id *oi, __u64 oid)
{
if (fid_seq_is_mdt0(oi->oi.oi_seq)) {
static inline int ostid_set_id(struct ost_id *oi, __u64 oid)
{
if (fid_seq_is_mdt0(oi->oi.oi_seq)) {
- if (oid >= IDIF_MAX_OID)
+ if (oid > IDIF_MAX_OID)
return -E2BIG;
oi->oi.oi_id = oid;
} else if (fid_is_idif(&oi->oi_fid)) {
return -E2BIG;
oi->oi.oi_id = oid;
} else if (fid_is_idif(&oi->oi_fid)) {
- if (oid >= IDIF_MAX_OID)
+ if (oid > IDIF_MAX_OID)
return -E2BIG;
oi->oi_fid.f_seq = fid_idif_seq(oid,
fid_idif_ost_idx(&oi->oi_fid));
oi->oi_fid.f_oid = oid;
oi->oi_fid.f_ver = oid >> 48;
} else {
return -E2BIG;
oi->oi_fid.f_seq = fid_idif_seq(oid,
fid_idif_ost_idx(&oi->oi_fid));
oi->oi_fid.f_oid = oid;
oi->oi_fid.f_ver = oid >> 48;
} else {
- if (oid >= OBIF_MAX_OID)
+ if (oid > OBIF_MAX_OID)
return -E2BIG;
oi->oi_fid.f_oid = oid;
}
return -E2BIG;
oi->oi_fid.f_oid = oid;
}
}
if (fid_is_idif(fid)) {
}
if (fid_is_idif(fid)) {
- if (oid >= IDIF_MAX_OID) {
+ if (oid > IDIF_MAX_OID) {
CERROR("Too large OID %#llx to set IDIF "DFID"\n",
(unsigned long long)oid, PFID(fid));
return -EBADF;
CERROR("Too large OID %#llx to set IDIF "DFID"\n",
(unsigned long long)oid, PFID(fid));
return -EBADF;
};
#define OBIF_OID_MAX_BITS 32
};
#define OBIF_OID_MAX_BITS 32
-#define OBIF_MAX_OID (1ULL << OBIF_OID_MAX_BITS)
-#define OBIF_OID_MASK ((1ULL << OBIF_OID_MAX_BITS) - 1)
+#define OBIF_MAX_OID ((1ULL << OBIF_OID_MAX_BITS) - 1)
#define IDIF_OID_MAX_BITS 48
#define IDIF_OID_MAX_BITS 48
-#define IDIF_MAX_OID (1ULL << IDIF_OID_MAX_BITS)
-#define IDIF_OID_MASK ((1ULL << IDIF_OID_MAX_BITS) - 1)
+#define IDIF_MAX_OID ((1ULL << IDIF_OID_MAX_BITS) - 1)
/** OID for FID_SEQ_SPECIAL */
enum special_oid {
/** OID for FID_SEQ_SPECIAL */
enum special_oid {
static inline __u64 ostid_id(const struct ost_id *ostid)
{
if (fid_seq_is_mdt0(ostid->oi.oi_seq))
static inline __u64 ostid_id(const struct ost_id *ostid)
{
if (fid_seq_is_mdt0(ostid->oi.oi_seq))
- return ostid->oi.oi_id & IDIF_OID_MASK;
+ return ostid->oi.oi_id & IDIF_MAX_OID;
if (fid_seq_is_default(ostid->oi.oi_seq))
return ostid->oi.oi_id;
if (fid_seq_is_default(ostid->oi.oi_seq))
return ostid->oi.oi_id;
* been in production for years. This can handle create rates
* of 1M objects/s/OST for 9 years, or combinations thereof.
*/
* been in production for years. This can handle create rates
* of 1M objects/s/OST for 9 years, or combinations thereof.
*/
- if (oid >= IDIF_MAX_OID)
+ if (oid > IDIF_MAX_OID)
return -EBADF;
fid->f_seq = fid_idif_seq(oid, ost_idx);
return -EBADF;
fid->f_seq = fid_idif_seq(oid, ost_idx);
diff = oid - ofd_seq_last_oid(oseq);
/* Do sync create if the seq is about to used up */
if (fid_seq_is_idif(seq) || fid_seq_is_mdt0(seq)) {
diff = oid - ofd_seq_last_oid(oseq);
/* Do sync create if the seq is about to used up */
if (fid_seq_is_idif(seq) || fid_seq_is_mdt0(seq)) {
- if (unlikely(oid >= IDIF_MAX_OID - 1))
+ if (unlikely(oid >= IDIF_MAX_OID))
sync_trans = 1;
} else if (fid_seq_is_norm(seq)) {
if (unlikely(oid >=
sync_trans = 1;
} else if (fid_seq_is_norm(seq)) {
if (unlikely(oid >=
/* Do sync create if the seq is about to used up */
if (fid_seq_is_idif(seq) || fid_seq_is_mdt0(seq)) {
/* Do sync create if the seq is about to used up */
if (fid_seq_is_idif(seq) || fid_seq_is_mdt0(seq)) {
- if (unlikely(oid >= IDIF_MAX_OID - 1))
+ if (unlikely(oid >= IDIF_MAX_OID))
sync = 1;
} else if (fid_seq_is_norm(seq)) {
if (unlikely(oid >=
sync = 1;
} else if (fid_seq_is_norm(seq)) {
if (unlikely(oid >=
- /* Don't create objects beyond the valid range for this SEQ */
+ /* Don't create objects beyond the valid range for this SEQ
+ * Last object to create is (id + nr - 1), but we move -1 on LHS
+ * to +1 on RHS to evaluate constant at compile time. LU-11186
+ */
if (unlikely(fid_seq_is_mdt0(ostid_seq(&oseq->os_oi)) &&
if (unlikely(fid_seq_is_mdt0(ostid_seq(&oseq->os_oi)) &&
- (id + nr) > IDIF_MAX_OID)) {
+ id + nr > IDIF_MAX_OID + 1)) {
CERROR("%s:"DOSTID" hit the IDIF_MAX_OID (1<<48)!\n",
ofd_name(ofd), id, ostid_seq(&oseq->os_oi));
RETURN(rc = -ENOSPC);
} else if (unlikely(!fid_seq_is_mdt0(ostid_seq(&oseq->os_oi)) &&
CERROR("%s:"DOSTID" hit the IDIF_MAX_OID (1<<48)!\n",
ofd_name(ofd), id, ostid_seq(&oseq->os_oi));
RETURN(rc = -ENOSPC);
} else if (unlikely(!fid_seq_is_mdt0(ostid_seq(&oseq->os_oi)) &&
- (id + nr) > OBIF_MAX_OID)) {
+ id + nr > OBIF_MAX_OID + 1)) {
CERROR("%s:"DOSTID" hit the OBIF_MAX_OID (1<<32)!\n",
ofd_name(ofd), id, ostid_seq(&oseq->os_oi));
RETURN(rc = -ENOSPC);
CERROR("%s:"DOSTID" hit the OBIF_MAX_OID (1<<32)!\n",
ofd_name(ofd), id, ostid_seq(&oseq->os_oi));
RETURN(rc = -ENOSPC);
- if (objid >= OBIF_MAX_OID) {
+ if (objid > OBIF_MAX_OID) {
fprintf(stderr, "error: %s: invalid objid '%s'\n",
jt_cmdname(argv[0]), argv[1]);
return CMD_HELP;
fprintf(stderr, "error: %s: invalid objid '%s'\n",
jt_cmdname(argv[0]), argv[1]);
return CMD_HELP;
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
- if (objid >= OBIF_MAX_OID) {
+ if (objid > OBIF_MAX_OID) {
fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
jt_cmdname(argv[0]), (unsigned long long)objid);
return -E2BIG;
fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
jt_cmdname(argv[0]), (unsigned long long)objid);
return -E2BIG;
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running();
i++, id++) {
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running();
i++, id++) {
- if (id >= OBIF_MAX_OID) {
+ if (id > OBIF_MAX_OID) {
fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
jt_cmdname(argv[0]), (unsigned long long)id);
return -E2BIG;
fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
jt_cmdname(argv[0]), (unsigned long long)id);
return -E2BIG;
if (*end == '\0') {
/* If str is a single number then assume old echo
* client usage. */
if (*end == '\0') {
/* If str is a single number then assume old echo
* client usage. */
- if (oid >= OBIF_MAX_OID)
+ if (oid > OBIF_MAX_OID)
return -EINVAL;
ostid_set_seq_echo(oi);
return -EINVAL;
ostid_set_seq_echo(oi);
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
- if (objid >= OBIF_MAX_OID) {
+ if (objid > OBIF_MAX_OID) {
fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
jt_cmdname(argv[0]), (unsigned long long)objid);
return -E2BIG;
fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
jt_cmdname(argv[0]), (unsigned long long)objid);
return -E2BIG;
#endif
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
#endif
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
- if (objid >= OBIF_MAX_OID) {
+ if (objid > OBIF_MAX_OID) {
fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
jt_cmdname(argv[0]), (unsigned long long)objid);
return -E2BIG;
fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
jt_cmdname(argv[0]), (unsigned long long)objid);
return -E2BIG;