* shouldn't cross unit boundaries.
*/
static int mgs_nidtbl_read(struct obd_export *exp, struct mgs_nidtbl *tbl,
- struct mgs_config_res *res, cfs_page_t **pages,
+ struct mgs_config_res *res, struct page **pages,
int nrpages, int units_total, int unit_size)
{
struct mgs_nidtbl_target *tgt;
/* make sure unit_size is power 2 */
LASSERT((unit_size & (unit_size - 1)) == 0);
- LASSERT(nrpages << CFS_PAGE_SHIFT >= units_total * unit_size);
+ LASSERT(nrpages << PAGE_CACHE_SHIFT >= units_total * unit_size);
mutex_lock(&tbl->mn_lock);
LASSERT(nidtbl_is_sane(tbl));
}
LASSERT((rc & (unit_size - 1)) == 0);
- if (units_in_page == 0) {
- /* allocate a new page */
- pages[index] = cfs_alloc_page(CFS_ALLOC_STD);
- if (pages[index] == NULL) {
- rc = -ENOMEM;
- break;
- }
+ if (units_in_page == 0) {
+ /* allocate a new page */
+ pages[index] = alloc_page(GFP_IOFS);
+ if (pages[index] == NULL) {
+ rc = -ENOMEM;
+ break;
+ }
- /* destroy previous map */
- if (index > 0)
- cfs_kunmap(pages[index - 1]);
+ /* destroy previous map */
+ if (index > 0)
+ kunmap(pages[index - 1]);
- /* reassign buffer */
- buf = cfs_kmap(pages[index]);
- ++index;
+ /* reassign buffer */
+ buf = kmap(pages[index]);
+ ++index;
- units_in_page = CFS_PAGE_SIZE / unit_size;
- LASSERT(units_in_page > 0);
- }
+ units_in_page = PAGE_CACHE_SIZE / unit_size;
+ LASSERT(units_in_page > 0);
+ }
/* allocate an unit */
LASSERT(((long)buf & (unit_size - 1)) == 0);
bytes_in_unit, index, nrpages, units_total);
}
if (index > 0)
- cfs_kunmap(pages[index - 1]);
+ kunmap(pages[index - 1]);
out:
LASSERT(version <= tbl->mn_version);
res->mcr_size = tbl->mn_version;
/* --------- Imperative Recovery relies on nidtbl stuff ------- */
void mgs_ir_notify_complete(struct fs_db *fsdb)
{
- struct timeval tv;
- cfs_duration_t delta;
+ struct timeval tv;
+ cfs_duration_t delta;
- cfs_atomic_set(&fsdb->fsdb_notify_phase, 0);
+ atomic_set(&fsdb->fsdb_notify_phase, 0);
/* do statistic */
fsdb->fsdb_notify_count++;
set_user_nice(current, -2);
- mgc_fsname2resid(fsdb->fsdb_name, &resid, CONFIG_T_RECOVER);
- while (1) {
- struct l_wait_info lwi = { 0 };
+ mgc_fsname2resid(fsdb->fsdb_name, &resid, CONFIG_T_RECOVER);
+ while (1) {
+ struct l_wait_info lwi = { 0 };
- l_wait_event(fsdb->fsdb_notify_waitq,
- fsdb->fsdb_notify_stop ||
- cfs_atomic_read(&fsdb->fsdb_notify_phase),
- &lwi);
- if (fsdb->fsdb_notify_stop)
- break;
+ l_wait_event(fsdb->fsdb_notify_waitq,
+ fsdb->fsdb_notify_stop ||
+ atomic_read(&fsdb->fsdb_notify_phase),
+ &lwi);
+ if (fsdb->fsdb_notify_stop)
+ break;
- CDEBUG(D_MGS, "%s woken up, phase is %d\n",
- name, cfs_atomic_read(&fsdb->fsdb_notify_phase));
+ CDEBUG(D_MGS, "%s woken up, phase is %d\n",
+ name, atomic_read(&fsdb->fsdb_notify_phase));
- fsdb->fsdb_notify_start = cfs_time_current();
+ fsdb->fsdb_notify_start = cfs_time_current();
mgs_revoke_lock(fsdb->fsdb_mgs, fsdb, CONFIG_T_RECOVER);
- }
+ }
complete(&fsdb->fsdb_notify_comp);
- return 0;
+ return 0;
}
int mgs_ir_init_fs(const struct lu_env *env, struct mgs_device *mgs,
struct fs_db *fsdb)
{
- cfs_task_t *task;
+ struct task_struct *task;
- if (!ir_timeout)
- ir_timeout = OBD_IR_MGS_TIMEOUT;
+ if (!ir_timeout)
+ ir_timeout = OBD_IR_MGS_TIMEOUT;
- fsdb->fsdb_ir_state = IR_FULL;
- if (cfs_time_before(cfs_time_current_sec(),
- mgs->mgs_start_time + ir_timeout))
- fsdb->fsdb_ir_state = IR_STARTUP;
- fsdb->fsdb_nonir_clients = 0;
- CFS_INIT_LIST_HEAD(&fsdb->fsdb_clients);
+ fsdb->fsdb_ir_state = IR_FULL;
+ if (cfs_time_before(cfs_time_current_sec(),
+ mgs->mgs_start_time + ir_timeout))
+ fsdb->fsdb_ir_state = IR_STARTUP;
+ fsdb->fsdb_nonir_clients = 0;
+ CFS_INIT_LIST_HEAD(&fsdb->fsdb_clients);
- /* start notify thread */
+ /* start notify thread */
fsdb->fsdb_mgs = mgs;
- cfs_atomic_set(&fsdb->fsdb_notify_phase, 0);
- cfs_waitq_init(&fsdb->fsdb_notify_waitq);
+ atomic_set(&fsdb->fsdb_notify_phase, 0);
+ init_waitqueue_head(&fsdb->fsdb_notify_waitq);
init_completion(&fsdb->fsdb_notify_comp);
task = kthread_run(mgs_ir_notify, fsdb,
CERROR("Start notify thread error %ld\n", PTR_ERR(task));
mgs_nidtbl_init_fs(env, fsdb);
- return 0;
+ return 0;
}
void mgs_ir_fini_fs(struct mgs_device *mgs, struct fs_db *fsdb)
{
if (test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags))
- return;
+ return;
- mgs_fsc_cleanup_by_fsdb(fsdb);
+ mgs_fsc_cleanup_by_fsdb(fsdb);
- mgs_nidtbl_fini_fs(fsdb);
+ mgs_nidtbl_fini_fs(fsdb);
- LASSERT(cfs_list_empty(&fsdb->fsdb_clients));
+ LASSERT(cfs_list_empty(&fsdb->fsdb_clients));
- fsdb->fsdb_notify_stop = 1;
- cfs_waitq_signal(&fsdb->fsdb_notify_waitq);
+ fsdb->fsdb_notify_stop = 1;
+ wake_up(&fsdb->fsdb_notify_waitq);
wait_for_completion(&fsdb->fsdb_notify_comp);
}
}
mutex_unlock(&fsdb->fsdb_mutex);
- LASSERT(ergo(mti->mti_flags & LDD_F_IR_CAPABLE, notify));
- if (notify) {
- CDEBUG(D_MGS, "Try to revoke recover lock of %s\n",
- fsdb->fsdb_name);
- cfs_atomic_inc(&fsdb->fsdb_notify_phase);
- cfs_waitq_signal(&fsdb->fsdb_notify_waitq);
- }
- return 0;
+ LASSERT(ergo(mti->mti_flags & LDD_F_IR_CAPABLE, notify));
+ if (notify) {
+ CDEBUG(D_MGS, "Try to revoke recover lock of %s\n",
+ fsdb->fsdb_name);
+ atomic_inc(&fsdb->fsdb_notify_phase);
+ wake_up(&fsdb->fsdb_notify_waitq);
+ }
+ return 0;
}
/* NID table can be cached by two entities: Clients and MDTs */
int bytes;
int page_count;
int nrpages;
- cfs_page_t **pages = NULL;
+ struct page **pages = NULL;
ENTRY;
body = req_capsule_client_get(&req->rq_pill, &RMF_MGS_CONFIG_BODY);
RETURN(rc);
bufsize = body->mcb_units << body->mcb_bits;
- nrpages = (bufsize + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
+ nrpages = (bufsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
if (nrpages > PTLRPC_MAX_BRW_PAGES)
RETURN(-EINVAL);
if (pages == NULL)
RETURN(-ENOMEM);
- rc = req_capsule_server_pack(&req->rq_pill);
- if (rc)
- GOTO(out, rc);
-
res = req_capsule_server_get(&req->rq_pill, &RMF_MGS_CONFIG_RES);
if (res == NULL)
GOTO(out, rc = -EINVAL);
res->mcr_offset = body->mcb_offset;
- unit_size = min_t(int, 1 << body->mcb_bits, CFS_PAGE_SIZE);
+ unit_size = min_t(int, 1 << body->mcb_bits, PAGE_CACHE_SIZE);
bytes = mgs_nidtbl_read(req->rq_export, &fsdb->fsdb_nidtbl, res,
pages, nrpages, bufsize / unit_size, unit_size);
if (bytes < 0)
GOTO(out, rc = bytes);
/* start bulk transfer */
- page_count = (bytes + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
+ page_count = (bytes + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
LASSERT(page_count <= nrpages);
desc = ptlrpc_prep_bulk_exp(req, page_count, 1,
BULK_PUT_SOURCE, MGS_BULK_PORTAL);
for (i = 0; i < page_count && bytes > 0; i++) {
ptlrpc_prep_bulk_page_pin(desc, pages[i], 0,
- min_t(int, bytes, CFS_PAGE_SIZE));
- bytes -= CFS_PAGE_SIZE;
+ min_t(int, bytes, PAGE_CACHE_SIZE));
+ bytes -= PAGE_CACHE_SIZE;
}
rc = target_bulk_io(req->rq_export, desc, &lwi);
for (i = 0; i < nrpages; i++) {
if (pages[i] == NULL)
break;
- cfs_free_page(pages[i]);
+ __free_page(pages[i]);
}
OBD_FREE(pages, sizeof(*pages) * nrpages);
return rc;
char *ptr;
int rc = 0;
- if (count > CFS_PAGE_SIZE)
+ if (count > PAGE_CACHE_SIZE)
return -EINVAL;
OBD_ALLOC(kbuf, count + 1);