Motr  M0
acc_cp.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #ifndef M0_TRACE_SUBSYSTEM
24 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_SNSCM
25 #endif
26 #include "lib/trace.h"
27 #include "lib/memory.h" /* m0_free() */
28 #include "lib/misc.h"
29 
30 #include "fop/fom.h"
31 #include "cob/cob.h"
32 #include "reqh/reqh.h"
33 
34 #include "sns/cm/cp.h"
35 #include "sns/cm/cm.h"
36 #include "sns/cm/repair/ag.h"
37 #include "sns/cm/cm_utils.h"
38 
53 M0_INTERNAL int m0_sns_cm_repair_cp_xform(struct m0_cm_cp *cp);
54 M0_INTERNAL int m0_sns_cm_repair_cp_send(struct m0_cm_cp *cp);
55 M0_INTERNAL int m0_sns_cm_repair_cp_recv_wait(struct m0_cm_cp *cp);
56 
57 static void acc_cp_free(struct m0_cm_cp *cp)
58 {
61 
62  M0_PRE(cp != NULL);
63 
67  if (fc->fc_is_inuse && fc->fc_is_active) {
69  fc->fc_is_active = false;
70  m0_cm_ag_cp_del(cp->c_ag, cp);
71  }
72 }
73 
74 static int acc_cp_fini(struct m0_cm_cp *cp)
75 {
76 
77  return 0;
78 }
79 
81  .co_action = {
94  /* To satisfy the m0_cm_cp_invariant() */
96  },
97  .co_action_nr = M0_CCP_NR,
98  .co_phase_next = &m0_sns_cm_cp_phase_next,
99  .co_invariant = &m0_sns_cm_cp_invariant,
100  .co_home_loc_helper = &cp_home_loc_helper,
101  .co_complete = &m0_sns_cm_cp_complete,
102  .co_free = &acc_cp_free,
103 };
104 
108 M0_INTERNAL void m0_sns_cm_acc_cp_init(struct m0_sns_cm_cp *scp,
109  struct m0_sns_cm_ag *sag)
110 {
111  struct m0_cm_cp *cp = &scp->sc_base;
112 
113  M0_PRE(scp != NULL);
114 
117  /*
118  * Initialise the bitmap representing the copy packets
119  * which will be transformed into the resultant copy
120  * packet.
121  */
125 }
126 
130 M0_INTERNAL int m0_sns_cm_acc_cp_setup(struct m0_sns_cm_cp *scp,
131  struct m0_fid *tgt_cobfid,
132  uint64_t tgt_cob_index,
133  uint64_t failed_unit_idx,
134  uint64_t data_seg_nr)
135 {
136  struct m0_sns_cm_ag *sag = ag2snsag(scp->sc_base.c_ag);
137  struct m0_cm *cm = sag->sag_base.cag_cm;
138  struct m0_sns_cm_repair_ag_failure_ctx *rag_fc;
139 
140  M0_PRE(scp != NULL && sag != NULL);
142 
144  scp->sc_is_local = true;
145  scp->sc_is_acc = true;
146  rag_fc = M0_AMB(rag_fc, scp, fc_tgt_acc_cp);
147  return m0_sns_cm_cp_setup(scp, tgt_cobfid, tgt_cob_index, data_seg_nr,
148  failed_unit_idx, rag_fc->fc_tgt_idx);
149 }
150 
152 /*
153  * Local variables:
154  * c-indentation-style: "K&R"
155  * c-basic-offset: 8
156  * tab-width: 8
157  * fill-column: 80
158  * scroll-step: 1
159  * End:
160  */
M0_INTERNAL int m0_sns_cm_repair_cp_recv_wait(struct m0_cm_cp *cp)
M0_INTERNAL int m0_sns_cm_cp_init(struct m0_cm_cp *cp)
Definition: cp.c:100
#define M0_PRE(cond)
M0_INTERNAL int m0_bitmap_init(struct m0_bitmap *map, size_t nr)
Definition: bitmap.c:86
M0_INTERNAL void m0_cm_ag_cp_del(struct m0_cm_aggr_group *ag, struct m0_cm_cp *cp)
Definition: ag.c:520
#define NULL
Definition: misc.h:38
M0_INTERNAL int m0_sns_cm_cp_send_wait(struct m0_cm_cp *cp)
Definition: net.c:297
struct m0_bitmap c_xform_cp_indices
Definition: cp.h:181
M0_INTERNAL void m0_sns_cm_acc_cp_init(struct m0_sns_cm_cp *scp, struct m0_sns_cm_ag *sag)
Definition: acc_cp.c:108
Definition: cp.h:160
M0_INTERNAL int m0_sns_cm_cp_recv_wait(struct m0_cm_cp *cp)
Definition: net.c:512
M0_INTERNAL void m0_sns_cm_cp_complete(struct m0_cm_cp *cp)
Definition: cp.c:307
M0_INTERNAL void m0_cm_cp_fom_init(struct m0_cm *cm, struct m0_cm_cp *cp, struct m0_fop *fop, struct m0_fop *r_fop)
Definition: cp.c:610
#define container_of(ptr, type, member)
Definition: misc.h:33
uint64_t cag_cp_global_nr
Definition: ag.h:86
M0_INTERNAL int m0_sns_cm_cp_write_pre(struct m0_cm_cp *cp)
Definition: storage.c:330
static struct m0_cm * cm
Definition: cm.c:63
Definition: cp.h:151
M0_INTERNAL void m0_cm_ag_cp_add(struct m0_cm_aggr_group *ag, struct m0_cm_cp *cp)
Definition: ag.c:510
static struct m0_sns_cm_ag * sag
Definition: cm.c:66
M0_INTERNAL int m0_sns_cm_acc_cp_setup(struct m0_sns_cm_cp *scp, struct m0_fid *tgt_cobfid, uint64_t tgt_cob_index, uint64_t failed_unit_idx, uint64_t data_seg_nr)
Definition: acc_cp.c:130
struct m0_cm_cp sc_base
Definition: cp.h:39
static void acc_cp_free(struct m0_cm_cp *cp)
Definition: acc_cp.c:57
M0_INTERNAL int m0_sns_cm_cp_recv_init(struct m0_cm_cp *cp)
Definition: net.c:432
#define M0_AMB(obj, ptr, field)
Definition: misc.h:320
M0_INTERNAL int m0_sns_cm_cp_write(struct m0_cm_cp *cp)
Definition: storage.c:335
M0_INTERNAL int m0_sns_cm_cp_io_wait(struct m0_cm_cp *cp)
Definition: storage.c:341
M0_INTERNAL int m0_sns_cm_cp_phase_next(struct m0_cm_cp *cp)
Definition: cp.c:261
struct m0_cm * cag_cm
Definition: ag.h:70
const struct m0_cm_cp_ops * c_ops
Definition: cp.h:169
M0_INTERNAL int m0_sns_cm_cp_setup(struct m0_sns_cm_cp *scp, const struct m0_fid *cob_fid, uint64_t stob_offset, uint64_t data_seg_nr, uint64_t failed_unit_index, uint64_t ag_cp_idx)
Definition: cp.c:368
M0_INTERNAL bool m0_sns_cm_cp_invariant(const struct m0_cm_cp *cp)
Definition: cp.c:62
int(* co_action[])(struct m0_cm_cp *cp)
Definition: cp.h:259
const struct m0_cm_cp_ops m0_sns_cm_acc_cp_ops
Definition: acc_cp.c:80
struct m0_sns_cm_cp fc_tgt_acc_cp
Definition: ag.h:45
struct m0_cm_aggr_group * c_ag
Definition: cp.h:172
M0_INTERNAL struct m0_sns_cm_cp * cp2snscp(const struct m0_cm_cp *cp)
Definition: cp.c:57
M0_INTERNAL int m0_sns_cm_cp_read(struct m0_cm_cp *cp)
Definition: storage.c:324
M0_INTERNAL int m0_sns_cm_repair_cp_send(struct m0_cm_cp *cp)
Definition: net.c:37
#define M0_CNT_INC(cnt)
Definition: arith.h:226
static int acc_cp_fini(struct m0_cm_cp *cp)
Definition: acc_cp.c:74
Definition: fid.h:38
static struct m0_sns_cm_cp scp
Definition: cm.c:65
bool sc_is_local
Definition: cp.h:53
Definition: cm.h:166
uint32_t rag_acc_freed
Definition: ag.h:83
M0_INTERNAL int m0_sns_cm_cp_fail(struct m0_cm_cp *cp)
Definition: cp.c:216
M0_INTERNAL void m0_sns_cm_cp_buf_release(struct m0_cm_cp *cp)
Definition: cp.c:326
static struct m0_sns_cm_repair_ag rag
Definition: net.c:54
bool cag_has_incoming
Definition: ag.h:101
struct m0_cm_aggr_group sag_base
Definition: ag.h:46
M0_INTERNAL int m0_sns_cm_cp_sw_check(struct m0_cm_cp *cp)
Definition: net.c:541
bool sc_is_acc
Definition: cp.h:57
M0_INTERNAL uint64_t cp_home_loc_helper(const struct m0_cm_cp *cp)
Definition: cp.c:80
M0_INTERNAL bool m0_cm_is_locked(const struct m0_cm *cm)
Definition: cm.c:560
M0_INTERNAL int m0_sns_cm_repair_cp_xform(struct m0_cm_cp *cp)
Definition: xform.c:222
M0_INTERNAL struct m0_sns_cm_repair_ag * sag2repairag(const struct m0_sns_cm_ag *sag)
Definition: ag.c:61
M0_INTERNAL struct m0_sns_cm_ag * ag2snsag(const struct m0_cm_aggr_group *ag)
Definition: ag.c:391