* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#define DEBUG_SUBSYSTEM S_MGS
#define D_MGS D_CONFIG
-#ifdef __KERNEL__
+#include <linux/kthread.h>
#include <linux/pagemap.h>
-#endif
#include <obd.h>
#include <obd_class.h>
static int nidtbl_is_sane(struct mgs_nidtbl *tbl)
{
- struct mgs_nidtbl_target *tgt;
- int version = 0;
+ struct mgs_nidtbl_target *tgt;
+ int version = 0;
LASSERT(mutex_is_locked(&tbl->mn_lock));
- cfs_list_for_each_entry(tgt, &tbl->mn_targets, mnt_list) {
- if (!tgt->mnt_version)
- continue;
+ list_for_each_entry(tgt, &tbl->mn_targets, mnt_list) {
+ if (!tgt->mnt_version)
+ continue;
- if (version >= tgt->mnt_version)
- return 0;
+ if (version >= tgt->mnt_version)
+ return 0;
- version = tgt->mnt_version;
- }
- return 1;
+ version = tgt->mnt_version;
+ }
+ return 1;
}
/**
* otherwise, it's for clients, then llog entries for both OSTs and
* MDTs will be returned.
*/
- cfs_list_for_each_entry(tgt, &tbl->mn_targets, mnt_list) {
+ list_for_each_entry(tgt, &tbl->mn_targets, mnt_list) {
int entry_len = sizeof(*entry);
if (tgt->mnt_version < version)
break;
}
- /* check if we need to consume remaining bytes. */
- if (last_in_unit != NULL && bytes_in_unit) {
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 6, 50, 0)
- /* May need to swab back to update the length.*/
- if (exp->exp_need_mne_swab)
- lustre_swab_mgs_nidtbl_entry(last_in_unit);
-#endif
+ /* check if we need to consume remaining bytes. */
+ if (last_in_unit != NULL && bytes_in_unit) {
last_in_unit->mne_length += bytes_in_unit;
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 6, 50, 0)
- if (exp->exp_need_mne_swab)
- lustre_swab_mgs_nidtbl_entry(last_in_unit);
-#endif
- rc += bytes_in_unit;
- buf += bytes_in_unit;
- last_in_unit = NULL;
- }
- LASSERT((rc & (unit_size - 1)) == 0);
+ rc += bytes_in_unit;
+ buf += bytes_in_unit;
+ last_in_unit = NULL;
+ }
+ LASSERT((rc & (unit_size - 1)) == 0);
if (units_in_page == 0) {
/* allocate a new page */
entry->mne_type = tgt->mnt_type;
entry->mne_nid_type = 0;
entry->mne_nid_size = sizeof(lnet_nid_t);
- entry->mne_nid_count = mti->mti_nid_count;
- memcpy(entry->u.nids, mti->mti_nids,
- mti->mti_nid_count * sizeof(lnet_nid_t));
-
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 6, 50, 0)
- /* For LU-1644, swab entry for 2.2 clients. */
- if (exp->exp_need_mne_swab)
- lustre_swab_mgs_nidtbl_entry(entry);
-#endif
+ entry->mne_nid_count = mti->mti_nid_count;
+ memcpy(entry->u.nids, mti->mti_nids,
+ mti->mti_nid_count * sizeof(lnet_nid_t));
- version = tgt->mnt_version;
- rc += entry_len;
- buf += entry_len;
+ version = tgt->mnt_version;
+ rc += entry_len;
+ buf += entry_len;
bytes_in_unit -= entry_len;
last_in_unit = entry;
type &= ~LDD_F_SV_TYPE_MGS;
LASSERT(type != 0);
- tbl = &fsdb->fsdb_nidtbl;
+ tbl = &fsdb->fsdb_nidtbl;
mutex_lock(&tbl->mn_lock);
- cfs_list_for_each_entry(tgt, &tbl->mn_targets, mnt_list) {
- struct mgs_target_info *info = &tgt->mnt_mti;
+ list_for_each_entry(tgt, &tbl->mn_targets, mnt_list) {
+ struct mgs_target_info *info = &tgt->mnt_mti;
+
if (type == tgt->mnt_type &&
mti->mti_stripe_index == info->mti_stripe_index) {
found = true;
if (tgt == NULL)
GOTO(out, rc = -ENOMEM);
- CFS_INIT_LIST_HEAD(&tgt->mnt_list);
- tgt->mnt_fs = tbl;
- tgt->mnt_version = 0; /* 0 means invalid */
- tgt->mnt_type = type;
+ INIT_LIST_HEAD(&tgt->mnt_list);
+ tgt->mnt_fs = tbl;
+ tgt->mnt_version = 0; /* 0 means invalid */
+ tgt->mnt_type = type;
- ++tbl->mn_nr_targets;
- }
+ ++tbl->mn_nr_targets;
+ }
- tgt->mnt_version = ++tbl->mn_version;
- tgt->mnt_mti = *mti;
+ tgt->mnt_version = ++tbl->mn_version;
+ tgt->mnt_mti = *mti;
- cfs_list_move_tail(&tgt->mnt_list, &tbl->mn_targets);
+ list_move_tail(&tgt->mnt_list, &tbl->mn_targets);
rc = nidtbl_update_version(env, fsdb->fsdb_mgs, tbl);
- EXIT;
+ EXIT;
out:
mutex_unlock(&tbl->mn_lock);
static void mgs_nidtbl_fini_fs(struct fs_db *fsdb)
{
struct mgs_nidtbl *tbl = &fsdb->fsdb_nidtbl;
- CFS_LIST_HEAD(head);
+ struct list_head head = LIST_HEAD_INIT(head);
mutex_lock(&tbl->mn_lock);
tbl->mn_nr_targets = 0;
- cfs_list_splice_init(&tbl->mn_targets, &head);
+ list_splice_init(&tbl->mn_targets, &head);
mutex_unlock(&tbl->mn_lock);
- while (!cfs_list_empty(&head)) {
+ while (!list_empty(&head)) {
struct mgs_nidtbl_target *tgt;
tgt = list_entry(head.next, struct mgs_nidtbl_target, mnt_list);
- cfs_list_del(&tgt->mnt_list);
+ list_del(&tgt->mnt_list);
OBD_FREE_PTR(tgt);
}
}
struct mgs_nidtbl *tbl = &fsdb->fsdb_nidtbl;
int rc;
- CFS_INIT_LIST_HEAD(&tbl->mn_targets);
+ INIT_LIST_HEAD(&tbl->mn_targets);
mutex_init(&tbl->mn_lock);
tbl->mn_nr_targets = 0;
tbl->mn_fsdb = fsdb;
mgs->mgs_start_time + ir_timeout))
fsdb->fsdb_ir_state = IR_STARTUP;
fsdb->fsdb_nonir_clients = 0;
- CFS_INIT_LIST_HEAD(&fsdb->fsdb_clients);
+ INIT_LIST_HEAD(&fsdb->fsdb_clients);
/* start notify thread */
fsdb->fsdb_mgs = mgs;
mgs_nidtbl_fini_fs(fsdb);
- LASSERT(cfs_list_empty(&fsdb->fsdb_clients));
+ LASSERT(list_empty(&fsdb->fsdb_clients));
fsdb->fsdb_notify_stop = 1;
wake_up(&fsdb->fsdb_notify_waitq);
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);
+ PTLRPC_BULK_PUT_SOURCE |
+ PTLRPC_BULK_BUF_KIOV,
+ MGS_BULK_PORTAL,
+ &ptlrpc_bulk_kiov_pin_ops);
if (desc == NULL)
GOTO(out, rc = -ENOMEM);
for (i = 0; i < page_count && bytes > 0; i++) {
- ptlrpc_prep_bulk_page_pin(desc, pages[i], 0,
- min_t(int, bytes, PAGE_CACHE_SIZE));
+ desc->bd_frag_ops->add_kiov_frag(desc, pages[i], 0,
+ min_t(int, bytes,
+ PAGE_CACHE_SIZE));
bytes -= PAGE_CACHE_SIZE;
}
rc = target_bulk_io(req->rq_export, desc, &lwi);
- ptlrpc_free_bulk_pin(desc);
+ ptlrpc_free_bulk(desc);
out:
for (i = 0; i < nrpages; i++) {
if (new_fsc == NULL)
RETURN(-ENOMEM);
- CFS_INIT_LIST_HEAD(&new_fsc->mfc_export_list);
- CFS_INIT_LIST_HEAD(&new_fsc->mfc_fsdb_list);
+ INIT_LIST_HEAD(&new_fsc->mfc_export_list);
+ INIT_LIST_HEAD(&new_fsc->mfc_fsdb_list);
new_fsc->mfc_fsdb = fsdb;
new_fsc->mfc_export = class_export_get(exp);
new_fsc->mfc_ir_capable = !!(exp_connect_flags(exp) &
/* tend to find it in export list because this list is shorter. */
spin_lock(&data->med_lock);
- cfs_list_for_each_entry(fsc, &data->med_clients, mfc_export_list) {
+ list_for_each_entry(fsc, &data->med_clients, mfc_export_list) {
if (strcmp(fsname, fsc->mfc_fsdb->fsdb_name) == 0) {
found = true;
break;
new_fsc = NULL;
/* add it into export list. */
- cfs_list_add(&fsc->mfc_export_list, &data->med_clients);
+ list_add(&fsc->mfc_export_list, &data->med_clients);
/* add into fsdb list. */
- cfs_list_add(&fsc->mfc_fsdb_list, &fsdb->fsdb_clients);
+ list_add(&fsc->mfc_fsdb_list, &fsdb->fsdb_clients);
if (!fsc->mfc_ir_capable) {
++fsdb->fsdb_nonir_clients;
if (fsdb->fsdb_ir_state == IR_FULL)
{
struct mgs_export_data *data = &exp->u.eu_mgs_data;
struct mgs_fsc *fsc, *tmp;
- CFS_LIST_HEAD(head);
+ struct list_head head = LIST_HEAD_INIT(head);
spin_lock(&data->med_lock);
- cfs_list_splice_init(&data->med_clients, &head);
+ list_splice_init(&data->med_clients, &head);
spin_unlock(&data->med_lock);
- cfs_list_for_each_entry_safe(fsc, tmp, &head, mfc_export_list) {
+ list_for_each_entry_safe(fsc, tmp, &head, mfc_export_list) {
struct fs_db *fsdb = fsc->mfc_fsdb;
LASSERT(fsc->mfc_export == exp);
mutex_lock(&fsdb->fsdb_mutex);
- cfs_list_del_init(&fsc->mfc_fsdb_list);
+ list_del_init(&fsc->mfc_fsdb_list);
if (fsc->mfc_ir_capable == 0) {
--fsdb->fsdb_nonir_clients;
LASSERT(fsdb->fsdb_ir_state != IR_FULL);
fsdb->fsdb_ir_state = IR_FULL;
}
mutex_unlock(&fsdb->fsdb_mutex);
- cfs_list_del_init(&fsc->mfc_export_list);
+ list_del_init(&fsc->mfc_export_list);
class_export_put(fsc->mfc_export);
OBD_FREE_PTR(fsc);
}
{
struct mgs_fsc *fsc, *tmp;
- cfs_list_for_each_entry_safe(fsc, tmp, &fsdb->fsdb_clients,
+ list_for_each_entry_safe(fsc, tmp, &fsdb->fsdb_clients,
mfc_fsdb_list) {
struct mgs_export_data *data = &fsc->mfc_export->u.eu_mgs_data;
LASSERT(fsdb == fsc->mfc_fsdb);
- cfs_list_del_init(&fsc->mfc_fsdb_list);
+ list_del_init(&fsc->mfc_fsdb_list);
spin_lock(&data->med_lock);
- cfs_list_del_init(&fsc->mfc_export_list);
+ list_del_init(&fsc->mfc_export_list);
spin_unlock(&data->med_lock);
class_export_put(fsc->mfc_export);
OBD_FREE_PTR(fsc);