X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ffid%2Ffid_store.c;h=1565d80811d2907524639c143124d533e97e7511;hp=77d4aedafa17fcc4b3baf55f7877eca1dc36edff;hb=917655fc2938b90a9c246dd2d58408c42aa1658d;hpb=4e84c438bb6cac63c2f4af25affda7651a98dcde diff --git a/lustre/fid/fid_store.c b/lustre/fid/fid_store.c index 77d4aed..1565d80 100644 --- a/lustre/fid/fid_store.c +++ b/lustre/fid/fid_store.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2012, Whamcloud, Inc. + * Copyright (c) 2011, 2017, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -42,24 +38,13 @@ #define DEBUG_SUBSYSTEM S_FID -#ifdef __KERNEL__ -# include -# include -#else /* __KERNEL__ */ -# include -#endif - -#include -#include +#include #include -#include #include -#include #include +#include #include "fid_internal.h" -#ifdef __KERNEL__ - static struct lu_buf *seq_store_buf(struct seq_thread_info *info) { struct lu_buf *buf; @@ -103,9 +88,8 @@ int seq_update_cb_add(struct thandle *th, struct lu_server_seq *seq) dcb = &ccb->suc_cb; dcb->dcb_func = seq_update_cb; - CFS_INIT_LIST_HEAD(&dcb->dcb_linkage); - strncpy(dcb->dcb_name, "seq_update_cb", MAX_COMMIT_CB_STR_LEN); - dcb->dcb_name[MAX_COMMIT_CB_STR_LEN - 1] = '\0'; + INIT_LIST_HEAD(&dcb->dcb_linkage); + strlcpy(dcb->dcb_name, "seq_update_cb", sizeof(dcb->dcb_name)); rc = dt_trans_cb_add(th, dcb); if (rc) @@ -123,6 +107,9 @@ int seq_store_update(const struct lu_env *env, struct lu_server_seq *seq, loff_t pos = 0; int rc; + if (dt_dev->dd_rdonly) + RETURN(0); + info = lu_context_key_get(&env->le_ctx, &seq_thread_key); LASSERT(info != NULL); @@ -130,49 +117,50 @@ int seq_store_update(const struct lu_env *env, struct lu_server_seq *seq, if (IS_ERR(th)) RETURN(PTR_ERR(th)); + /* Store ranges in le format. */ + range_cpu_to_le(&info->sti_space, &seq->lss_space); + rc = dt_declare_record_write(env, seq->lss_obj, - sizeof(struct lu_seq_range), 0, th); - if (rc) - GOTO(exit, rc); - - if (out != NULL) { - rc = fld_declare_server_create(seq->lss_site->ms_server_fld, - env, th); - if (rc) - GOTO(exit, rc); - } + seq_store_buf(info), 0, th); + if (rc) + GOTO(exit, rc); - rc = dt_trans_start_local(env, dt_dev, th); - if (rc) - GOTO(exit, rc); + if (out != NULL) { + rc = fld_declare_server_create(env, + seq->lss_site->ss_server_fld, + out, th); + if (rc) + GOTO(exit, rc); + } - /* Store ranges in le format. */ - range_cpu_to_le(&info->sti_space, &seq->lss_space); + rc = dt_trans_start_local(env, dt_dev, th); + if (rc) + GOTO(exit, rc); rc = dt_record_write(env, seq->lss_obj, seq_store_buf(info), &pos, th); - if (rc) { - CERROR("%s: Can't write space data, rc %d\n", - seq->lss_name, rc); + if (rc) { + CERROR("%s: Can't write space data, rc %d\n", + seq->lss_name, rc); GOTO(exit, rc); - } else if (out != NULL) { - rc = fld_server_create(seq->lss_site->ms_server_fld, - env, out, th); - if (rc) { - CERROR("%s: Can't Update fld database, rc %d\n", - seq->lss_name, rc); + } else if (out != NULL) { + rc = fld_server_create(env, seq->lss_site->ss_server_fld, out, + th); + if (rc) { + CERROR("%s: Can't Update fld database, rc %d\n", + seq->lss_name, rc); GOTO(exit, rc); - } - } - /* next sequence update will need sync until this update is committed - * in case of sync operation this is not needed obviously */ - if (!sync) - /* if callback can't be added then sync always */ - sync = !!seq_update_cb_add(th, seq); - - th->th_sync |= sync; + } + } + /* next sequence update will need sync until this update is committed + * in case of sync operation this is not needed obviously */ + if (!sync) + /* if callback can't be added then sync always */ + sync = !!seq_update_cb_add(th, seq); + + th->th_sync |= sync; exit: - dt_trans_stop(env, dt_dev, th); - return rc; + dt_trans_stop(env, dt_dev, th); + return rc; } /* @@ -190,9 +178,7 @@ int seq_store_read(struct lu_server_seq *seq, info = lu_context_key_get(&env->le_ctx, &seq_thread_key); LASSERT(info != NULL); - rc = seq->lss_obj->do_body_ops->dbo_read(env, seq->lss_obj, - seq_store_buf(info), - &pos, BYPASS_CAPA); + rc = dt_read(env, seq->lss_obj, seq_store_buf(info), &pos); if (rc == sizeof(info->sti_space)) { range_le_to_cpu(&seq->lss_space, &info->sti_space); @@ -248,17 +234,15 @@ int seq_store_init(struct lu_server_seq *seq, RETURN(rc); } -void seq_store_fini(struct lu_server_seq *seq, - const struct lu_env *env) +void seq_store_fini(struct lu_server_seq *seq, const struct lu_env *env) { - ENTRY; + ENTRY; - if (seq->lss_obj != NULL) { - if (!IS_ERR(seq->lss_obj)) - lu_object_put(env, &seq->lss_obj->do_lu); - seq->lss_obj = NULL; - } + if (seq->lss_obj != NULL) { + if (!IS_ERR(seq->lss_obj)) + dt_object_put(env, seq->lss_obj); + seq->lss_obj = NULL; + } - EXIT; + EXIT; } -#endif