*/
#define NRS_ORR_BITS 24
#define NRS_ORR_BKT_BITS 12
-#define NRS_ORR_HASH_FLAGS (CFS_HASH_RW_BKTLOCK | CFS_HASH_ASSERT_EMPTY)
+#define NRS_ORR_HASH_FLAGS (CFS_HASH_SPIN_BKTLOCK | CFS_HASH_ASSERT_EMPTY)
#define NRS_TRR_BITS 4
#define NRS_TRR_BKT_BITS 2
-#define NRS_TRR_HASH_FLAGS CFS_HASH_RW_BKTLOCK
+#define NRS_TRR_HASH_FLAGS CFS_HASH_SPIN_BKTLOCK
static unsigned nrs_orr_hop_hash(cfs_hash_t *hs, const void *key, unsigned mask)
{
struct nrs_orr_object *orro = cfs_hlist_entry(hnode,
struct nrs_orr_object,
oo_hnode);
- cfs_atomic_inc(&orro->oo_ref);
+ orro->oo_ref++;
}
/**
oo_hnode);
struct nrs_orr_data *orrd = container_of(orro->oo_res.res_parent,
struct nrs_orr_data, od_res);
- cfs_hash_bd_t bds[2];
+ cfs_hash_bd_t bd;
- if (cfs_atomic_dec_return(&orro->oo_ref) > 1)
- return;
+ cfs_hash_bd_get_and_lock(hs, &orro->oo_key, &bd, 1);
- cfs_hash_lock(hs, 0);
- cfs_hash_dual_bd_get_and_lock(hs, &orro->oo_key, bds, 1);
+ if (--orro->oo_ref > 1) {
+ cfs_hash_bd_unlock(hs, &bd, 1);
- /**
- * Another thread may have won the race and taken a reference on the
- * nrs_orr_object.
- */
- if (cfs_atomic_read(&orro->oo_ref) > 1)
- goto lost_race;
+ return;
+ }
+ LASSERT(orro->oo_ref == 1);
- if (bds[1].bd_bucket == NULL)
- cfs_hash_bd_del_locked(hs, &bds[0], hnode);
- else
- hnode = cfs_hash_dual_bd_finddel_locked(hs, bds, &orro->oo_key,
- hnode);
- LASSERT(hnode != NULL);
+ cfs_hash_bd_del_locked(hs, &bd, hnode);
+ cfs_hash_bd_unlock(hs, &bd, 1);
OBD_SLAB_FREE_PTR(orro, orrd->od_cache);
-
-lost_race:
-
- cfs_hash_dual_bd_unlock(hs, bds, 1);
- cfs_hash_unlock(hs, 0);
}
static void nrs_orr_hop_put(cfs_hash_t *hs, cfs_hlist_node_t *hnode)
struct nrs_orr_object *orro = cfs_hlist_entry(hnode,
struct nrs_orr_object,
oo_hnode);
- cfs_atomic_dec(&orro->oo_ref);
+ orro->oo_ref--;
}
static int nrs_trr_hop_keycmp(const void *key, cfs_hlist_node_t *hnode)
struct nrs_orr_data *orrd = container_of(orro->oo_res.res_parent,
struct nrs_orr_data, od_res);
- LASSERTF(cfs_atomic_read(&orro->oo_ref) == 0,
- "Busy NRS TRR policy object for OST with index %u, with %d "
- "refs\n", orro->oo_key.ok_idx, cfs_atomic_read(&orro->oo_ref));
+ LASSERTF(orro->oo_ref == 0,
+ "Busy NRS TRR policy object for OST with index %u, with %ld "
+ "refs\n", orro->oo_key.ok_idx, orro->oo_ref);
OBD_SLAB_FREE_PTR(orro, orrd->od_cache);
}
* backend-fs object (for ORR policy instances) or OST (for TRR policy
* instances).
*/
- if (nrq1->nr_u.orr.or_sequence < nrq2->nr_u.crr.cr_sequence)
+ if (nrq1->nr_u.orr.or_sequence < nrq2->nr_u.orr.or_sequence)
return 1;
- else if (nrq1->nr_u.orr.or_sequence > nrq2->nr_u.crr.cr_sequence)
+ else if (nrq1->nr_u.orr.or_sequence > nrq2->nr_u.orr.or_sequence)
return 0;
/**
/**
* Slab cache for NRS ORR/TRR objects.
*/
- orrd->od_cache = cfs_mem_cache_create(orrd->od_objname,
- sizeof(struct nrs_orr_object),
- 0, 0);
+ orrd->od_cache = kmem_cache_create(orrd->od_objname,
+ sizeof(struct nrs_orr_object),
+ 0, 0, NULL);
if (orrd->od_cache == NULL)
GOTO(failed, rc = -ENOMEM);
failed:
if (orrd->od_cache) {
- rc = cfs_mem_cache_destroy(orrd->od_cache);
+ kmem_cache_destroy(orrd->od_cache);
LASSERTF(rc == 0, "Could not destroy od_cache slab\n");
}
if (orrd->od_binheap != NULL)
cfs_binheap_destroy(orrd->od_binheap);
cfs_hash_putref(orrd->od_obj_hash);
- cfs_mem_cache_destroy(orrd->od_cache);
+ kmem_cache_destroy(orrd->od_cache);
OBD_FREE_PTR(orrd);
}
OBD_SLAB_CPT_ALLOC_PTR_GFP(orro, orrd->od_cache,
nrs_pol2cptab(policy), nrs_pol2cptid(policy),
- (moving_req ? CFS_ALLOC_ATOMIC :
- CFS_ALLOC_IO));
+ moving_req ? GFP_ATOMIC : __GFP_IO);
if (orro == NULL)
RETURN(-ENOMEM);
orro->oo_key = key;
- cfs_atomic_set(&orro->oo_ref, 1);
+ orro->oo_ref = 1;
tmp = cfs_hash_findadd_unique(orrd->od_obj_hash, &orro->oo_key,
&orro->oo_hnode);
orro->oo_quantum = orrd->od_quantum;
}
- nrq->nr_u.crr.cr_round = orro->oo_round;
- nrq->nr_u.crr.cr_sequence = orro->oo_sequence;
+ nrq->nr_u.orr.or_round = orro->oo_round;
+ nrq->nr_u.orr.or_sequence = orro->oo_sequence;
rc = cfs_binheap_insert(orrd->od_binheap, &nrq->nr_node);
if (rc == 0) {
* XXX: the CRR-N version of this, ptlrpc_lprocfs_rd_nrs_crrn_quantum() is
* almost identical; it can be reworked and then reused for ORR/TRR.
*/
-static int ptlrpc_lprocfs_rd_nrs_orr_quantum(char *page, char **start,
- off_t off, int count, int *eof,
- void *data)
+static int
+ptlrpc_lprocfs_nrs_orr_quantum_seq_show(struct seq_file *m, void *data)
{
- struct nrs_lprocfs_orr_data *orr_data = data;
+ struct nrs_lprocfs_orr_data *orr_data = m->private;
struct ptlrpc_service *svc = orr_data->svc;
__u16 quantum;
int rc;
- int rc2 = 0;
/**
* Perform two separate calls to this as only one of the NRS heads'
NRS_CTL_ORR_RD_QUANTUM,
true, &quantum);
if (rc == 0) {
- *eof = 1;
- rc2 = snprintf(page, count, NRS_LPROCFS_QUANTUM_NAME_REG
- "%-5d\n", quantum);
+ seq_printf(m, NRS_LPROCFS_QUANTUM_NAME_REG "%-5d\n", quantum);
/**
* Ignore -ENODEV as the regular NRS head's policy may be in the
* ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
orr_data->name, NRS_CTL_ORR_RD_QUANTUM,
true, &quantum);
if (rc == 0) {
- *eof = 1;
- rc2 += snprintf(page + rc2, count - rc2,
- NRS_LPROCFS_QUANTUM_NAME_HP"%-5d\n", quantum);
+ seq_printf(m, NRS_LPROCFS_QUANTUM_NAME_HP"%-5d\n", quantum);
/**
* Ignore -ENODEV as the high priority NRS head's policy may be
* in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
no_hp:
- return rc2 ? : rc;
+ return rc;
}
/**
* XXX: the CRR-N version of this, ptlrpc_lprocfs_wr_nrs_crrn_quantum() is
* almost identical; it can be reworked and then reused for ORR/TRR.
*/
-static int ptlrpc_lprocfs_wr_nrs_orr_quantum(struct file *file,
- const char *buffer,
- unsigned long count, void *data)
+static ssize_t
+ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file, const char *buffer,
+ size_t count, loff_t *off)
{
- struct nrs_lprocfs_orr_data *orr_data = data;
+ struct seq_file *m = file->private_data;
+ struct nrs_lprocfs_orr_data *orr_data = m->private;
struct ptlrpc_service *svc = orr_data->svc;
enum ptlrpc_nrs_queue_type queue = 0;
char kernbuf[LPROCFS_NRS_WR_QUANTUM_MAX_CMD];
long quantum_reg;
long quantum_hp;
/** lprocfs_find_named_value() modifies its argument, so keep a copy */
- unsigned long count_copy;
+ size_t count_copy;
int rc = 0;
int rc2 = 0;
if (count > (sizeof(kernbuf) - 1))
return -EINVAL;
- if (cfs_copy_from_user(kernbuf, buffer, count))
+ if (copy_from_user(kernbuf, buffer, count))
return -EFAULT;
kernbuf[count] = '\0';
return rc == -ENODEV && rc2 == -ENODEV ? -ENODEV : count;
}
+LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_quantum);
#define LPROCFS_NRS_OFF_NAME_REG "reg_offset_type:"
#define LPROCFS_NRS_OFF_NAME_HP "hp_offset_type:"
* reg_offset_type:physical
* hp_offset_type:logical
*/
-static int ptlrpc_lprocfs_rd_nrs_orr_offset_type(char *page, char **start,
- off_t off, int count, int *eof,
- void *data)
+static int
+ptlrpc_lprocfs_nrs_orr_offset_type_seq_show(struct seq_file *m, void *data)
{
- struct nrs_lprocfs_orr_data *orr_data = data;
+ struct nrs_lprocfs_orr_data *orr_data = m->private;
struct ptlrpc_service *svc = orr_data->svc;
bool physical;
int rc;
- int rc2 = 0;
/**
* Perform two separate calls to this as only one of the NRS heads'
orr_data->name, NRS_CTL_ORR_RD_OFF_TYPE,
true, &physical);
if (rc == 0) {
- *eof = 1;
- rc2 = snprintf(page, count,
- LPROCFS_NRS_OFF_NAME_REG"%s\n",
- physical ? LPROCFS_NRS_OFF_NAME_PHYSICAL :
- LPROCFS_NRS_OFF_NAME_LOGICAL);
+ seq_printf(m, LPROCFS_NRS_OFF_NAME_REG"%s\n",
+ physical ? LPROCFS_NRS_OFF_NAME_PHYSICAL :
+ LPROCFS_NRS_OFF_NAME_LOGICAL);
/**
* Ignore -ENODEV as the regular NRS head's policy may be in the
* ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
orr_data->name, NRS_CTL_ORR_RD_OFF_TYPE,
true, &physical);
if (rc == 0) {
- *eof = 1;
- rc2 += snprintf(page + rc2, count - rc2,
- LPROCFS_NRS_OFF_NAME_HP"%s\n",
- physical ? LPROCFS_NRS_OFF_NAME_PHYSICAL :
- LPROCFS_NRS_OFF_NAME_LOGICAL);
+ seq_printf(m, LPROCFS_NRS_OFF_NAME_HP"%s\n",
+ physical ? LPROCFS_NRS_OFF_NAME_PHYSICAL :
+ LPROCFS_NRS_OFF_NAME_LOGICAL);
/**
* Ignore -ENODEV as the high priority NRS head's policy may be
* in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
}
no_hp:
-
- return rc2 ? : rc;
+ return rc;
}
/**
* policy instances in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state are
* are skipped later by nrs_orr_ctl().
*/
-static int ptlrpc_lprocfs_wr_nrs_orr_offset_type(struct file *file,
- const char *buffer,
- unsigned long count,
- void *data)
+static ssize_t
+ptlrpc_lprocfs_nrs_orr_offset_type_seq_write(struct file *file,
+ const char *buffer, size_t count,
+ loff_t *off)
{
- struct nrs_lprocfs_orr_data *orr_data = data;
+ struct seq_file *m = file->private_data;
+ struct nrs_lprocfs_orr_data *orr_data = m->private;
struct ptlrpc_service *svc = orr_data->svc;
enum ptlrpc_nrs_queue_type queue = 0;
char kernbuf[LPROCFS_NRS_WR_OFF_TYPE_MAX_CMD];
char *val_hp;
bool physical_reg;
bool physical_hp;
- unsigned long count_copy;
+ size_t count_copy;
int rc = 0;
int rc2 = 0;
if (count > (sizeof(kernbuf) - 1))
return -EINVAL;
- if (cfs_copy_from_user(kernbuf, buffer, count))
+ if (copy_from_user(kernbuf, buffer, count))
return -EFAULT;
kernbuf[count] = '\0';
return rc == -ENODEV && rc2 == -ENODEV ? -ENODEV : count;
}
+LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_offset_type);
#define NRS_LPROCFS_REQ_SUPP_NAME_REG "reg_supported:"
#define NRS_LPROCFS_REQ_SUPP_NAME_HP "hp_supported:"
* reg_supported:reads
* hp_supported:reads_and_writes
*/
-static int ptlrpc_lprocfs_rd_nrs_orr_supported(char *page, char **start,
- off_t off, int count, int *eof,
- void *data)
+static int
+ptlrpc_lprocfs_nrs_orr_supported_seq_show(struct seq_file *m, void *data)
{
- struct nrs_lprocfs_orr_data *orr_data = data;
+ struct nrs_lprocfs_orr_data *orr_data = m->private;
struct ptlrpc_service *svc = orr_data->svc;
enum nrs_orr_supp supported;
int rc;
- int rc2 = 0;
/**
* Perform two separate calls to this as only one of the NRS heads'
&supported);
if (rc == 0) {
- *eof = 1;
- rc2 = snprintf(page, count,
- NRS_LPROCFS_REQ_SUPP_NAME_REG"%s\n",
- nrs_orr_supp2str(supported));
+ seq_printf(m, NRS_LPROCFS_REQ_SUPP_NAME_REG"%s\n",
+ nrs_orr_supp2str(supported));
/**
* Ignore -ENODEV as the regular NRS head's policy may be in the
* ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
NRS_CTL_ORR_RD_SUPP_REQ, true,
&supported);
if (rc == 0) {
- *eof = 1;
- rc2 += snprintf(page + rc2, count - rc2,
- NRS_LPROCFS_REQ_SUPP_NAME_HP"%s\n",
- nrs_orr_supp2str(supported));
+ seq_printf(m, NRS_LPROCFS_REQ_SUPP_NAME_HP"%s\n",
+ nrs_orr_supp2str(supported));
/**
* Ignore -ENODEV as the high priority NRS head's policy may be
* in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
no_hp:
- return rc2 ? : rc;
+ return rc;
}
/**
* policy instances in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state are
* are skipped later by nrs_orr_ctl().
*/
-static int ptlrpc_lprocfs_wr_nrs_orr_supported(struct file *file,
- const char *buffer,
- unsigned long count, void *data)
+static ssize_t
+ptlrpc_lprocfs_nrs_orr_supported_seq_write(struct file *file,
+ const char *buffer, size_t count,
+ loff_t *off)
{
- struct nrs_lprocfs_orr_data *orr_data = data;
+ struct seq_file *m = file->private_data;
+ struct nrs_lprocfs_orr_data *orr_data = m->private;
struct ptlrpc_service *svc = orr_data->svc;
enum ptlrpc_nrs_queue_type queue = 0;
char kernbuf[LPROCFS_NRS_WR_REQ_SUPP_MAX_CMD];
char *val_hp;
enum nrs_orr_supp supp_reg;
enum nrs_orr_supp supp_hp;
- unsigned long count_copy;
+ size_t count_copy;
int rc = 0;
int rc2 = 0;
if (count > (sizeof(kernbuf) - 1))
return -EINVAL;
- if (cfs_copy_from_user(kernbuf, buffer, count))
+ if (copy_from_user(kernbuf, buffer, count))
return -EFAULT;
kernbuf[count] = '\0';
return rc == -ENODEV && rc2 == -ENODEV ? -ENODEV : count;
}
+LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_supported);
int nrs_orr_lprocfs_init(struct ptlrpc_service *svc)
{
- int rc;
int i;
- struct lprocfs_vars nrs_orr_lprocfs_vars[] = {
+ struct lprocfs_seq_vars nrs_orr_lprocfs_vars[] = {
{ .name = "nrs_orr_quantum",
- .read_fptr = ptlrpc_lprocfs_rd_nrs_orr_quantum,
- .write_fptr = ptlrpc_lprocfs_wr_nrs_orr_quantum },
+ .fops = &ptlrpc_lprocfs_nrs_orr_quantum_fops },
{ .name = "nrs_orr_offset_type",
- .read_fptr = ptlrpc_lprocfs_rd_nrs_orr_offset_type,
- .write_fptr = ptlrpc_lprocfs_wr_nrs_orr_offset_type },
+ .fops = &ptlrpc_lprocfs_nrs_orr_offset_type_fops },
{ .name = "nrs_orr_supported",
- .read_fptr = ptlrpc_lprocfs_rd_nrs_orr_supported,
- .write_fptr = ptlrpc_lprocfs_wr_nrs_orr_supported },
+ .fops = &ptlrpc_lprocfs_nrs_orr_supported_fops },
{ NULL }
};
for (i = 0; i < ARRAY_SIZE(nrs_orr_lprocfs_vars); i++)
nrs_orr_lprocfs_vars[i].data = &lprocfs_orr_data;
- rc = lprocfs_add_vars(svc->srv_procroot, nrs_orr_lprocfs_vars, NULL);
-
- return rc;
+ return lprocfs_seq_add_vars(svc->srv_procroot, nrs_orr_lprocfs_vars, NULL);
}
void nrs_orr_lprocfs_fini(struct ptlrpc_service *svc)
int rc;
int i;
- struct lprocfs_vars nrs_trr_lprocfs_vars[] = {
+ struct lprocfs_seq_vars nrs_trr_lprocfs_vars[] = {
{ .name = "nrs_trr_quantum",
- .read_fptr = ptlrpc_lprocfs_rd_nrs_orr_quantum,
- .write_fptr = ptlrpc_lprocfs_wr_nrs_orr_quantum },
+ .fops = &ptlrpc_lprocfs_nrs_orr_quantum_fops },
{ .name = "nrs_trr_offset_type",
- .read_fptr = ptlrpc_lprocfs_rd_nrs_orr_offset_type,
- .write_fptr = ptlrpc_lprocfs_wr_nrs_orr_offset_type },
+ .fops = &ptlrpc_lprocfs_nrs_orr_offset_type_fops },
{ .name = "nrs_trr_supported",
- .read_fptr = ptlrpc_lprocfs_rd_nrs_orr_supported,
- .write_fptr = ptlrpc_lprocfs_wr_nrs_orr_supported },
+ .fops = &ptlrpc_lprocfs_nrs_orr_supported_fops },
{ NULL }
};
for (i = 0; i < ARRAY_SIZE(nrs_trr_lprocfs_vars); i++)
nrs_trr_lprocfs_vars[i].data = &lprocfs_trr_data;
- rc = lprocfs_add_vars(svc->srv_procroot, nrs_trr_lprocfs_vars, NULL);
+ rc = lprocfs_seq_add_vars(svc->srv_procroot, nrs_trr_lprocfs_vars, NULL);
return rc;
}