Motr  M0
m0t1fs.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_M0T1FS
23 #include "lib/trace.h"
24 
25 #include <linux/module.h>
26 #include <linux/init.h>
27 
29 #include "lib/memory.h"
30 #include "fid/fid.h"
31 #include "ioservice/io_fops.h"
32 #include "mdservice/md_fops.h"
33 #include "rpc/rpclib.h"
34 #include "rm/rm.h"
36 #include "mdservice/fsync_fops.h"
37 #include "sss/process_fops.h" /* m0_ss_process_fops_init */
38 #include "ha/note_fops.h"
39 #include "addb2/global.h"
40 #include "addb2/sys.h"
41 
45 
46 static struct file_system_type m0t1fs_fs_type = {
47  .owner = THIS_MODULE,
48  .name = "m0t1fs",
49 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
50  .mount = m0t1fs_mount,
51 #else
52  .get_sb = m0t1fs_get_sb,
53 #endif
54  .kill_sb = m0t1fs_kill_sb,
55  .fs_flags = FS_BINARY_MOUNTDATA
56 };
57 
58 M0_INTERNAL int m0t1fs_init(void)
59 {
60  struct m0_addb2_sys *sys = m0_addb2_global_get();
61  int rc;
62  int cpus;
63 
64  M0_ENTRY();
66  /*
67  * [1 - M0_NET_LNET_TMID_MAX / 2] for clients.
68  * [M0_NET_LNET_TMID_MAX / 2 - M0_NET_LNET_TMID_MAX] for server ep.
69  */
71  if (rc != 0)
72  goto out;
74 
76  if (rc != 0)
77  goto bitmap_fini;
78 
80  if (rc != 0)
81  goto fsync_fini;
82 
84  if (rc != 0)
85  goto ioservice_fop_fini;
86 
88  if (rc != 0)
89  goto mdservice_fop_fini;
90 
92  if (rc != 0)
93  goto process_fops_fini;
94 
97  if (rc != 0)
98  goto icache_fini;
99 
100  rc = register_filesystem(&m0t1fs_fs_type);
101  if (rc != 0)
102  goto addb2_fini;
103  /*
104  * Limit the number of concurrent parity calculations
105  * to avoid starving other threads (especially LNet) out.
106  *
107  * Note: the exact threshold number may come from configuration
108  * database later where it can be specified per-node.
109  */
110  cpus = (num_online_cpus() / 2) ?: 1;
111  printk(KERN_INFO "motr: max CPUs for parity calcs: %d\n", cpus);
113  return M0_RC(0);
114 
115 addb2_fini:
118 icache_fini:
120 process_fops_fini:
122 mdservice_fop_fini:
124 ioservice_fop_fini:
126 fsync_fini:
128 bitmap_fini:
131 out:
132  return M0_ERR(rc);
133 }
134 
135 M0_INTERNAL void m0t1fs_fini(void)
136 {
137  struct m0_addb2_sys *sys;
139  M0_ENTRY();
140 
141  sys = m0_addb2_global_get();
142 
143  (void)unregister_filesystem(&m0t1fs_fs_type);
144 
154  M0_LEAVE();
155 }
156 
157 #undef M0_TRACE_SUBSYSTEM
struct m0_mutex m0t1fs_mutex
Definition: m0t1fs.c:43
M0_INTERNAL int m0_bitmap_init(struct m0_bitmap *map, size_t nr)
Definition: bitmap.c:86
void m0_addb2_sys_net_stop(struct m0_addb2_sys *sys)
Definition: sys.c:322
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_bitmap_fini(struct m0_bitmap *map)
Definition: bitmap.c:97
M0_INTERNAL void m0_ha_state_fop_fini(void)
Definition: note_fops.c:37
void m0_addb2_sys_sm_stop(struct m0_addb2_sys *sys)
Definition: sys.c:384
M0_INTERNAL int m0t1fs_inode_cache_init(void)
Definition: inode.c:101
void m0_addb2_sys_sm_start(struct m0_addb2_sys *sys)
Definition: sys.c:377
M0_LEAVE()
M0_INTERNAL int m0_mdservice_fop_init(void)
Definition: md_fops.c:341
M0_INTERNAL struct dentry * m0t1fs_mount(struct file_system_type *fstype, int flags, const char *devname, void *data)
Definition: super.c:1372
M0_INTERNAL void m0_ss_process_fops_fini(void)
Definition: process_fops.c:102
M0_INTERNAL void m0t1fs_inode_cache_fini(void)
Definition: inode.c:118
return M0_RC(rc)
M0_INTERNAL int m0_ioservice_fop_init(void)
Definition: io_fops.c:281
#define M0_ENTRY(...)
Definition: trace.h:170
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL void m0_mdservice_fop_fini(void)
Definition: md_fops.c:348
M0_INTERNAL int m0_mdservice_fsync_fop_init(struct m0_reqh_service_type *svct)
Definition: fsync_fops.c:113
M0_INTERNAL void m0t1fs_fini(struct m0t1fs_conf *conf)
Definition: m0t1fs.c:237
M0_THREAD_ENTER
Definition: dir.c:336
M0_INTERNAL void m0t1fs_init(struct sim *s, struct m0t1fs_conf *conf)
Definition: m0t1fs.c:173
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
struct m0_semaphore m0t1fs_cpus_sem
Definition: m0t1fs.c:44
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
M0_INTERNAL void m0_bitmap_set(struct m0_bitmap *map, size_t idx, bool val)
Definition: bitmap.c:139
M0_INTERNAL void m0t1fs_kill_sb(struct super_block *sb)
Definition: super.c:1392
static struct file_system_type m0t1fs_fs_type
Definition: m0t1fs.c:46
M0_INTERNAL int m0_ss_process_fops_init(void)
Definition: process_fops.c:56
struct m0_bitmap m0t1fs_client_ep_tmid
Definition: m0t1fs.c:42
M0_INTERNAL void m0_ioservice_fop_fini(void)
Definition: io_fops.c:251
M0_INTERNAL struct m0_addb2_sys * m0_addb2_global_get(void)
Definition: global.c:99
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
int m0_addb2_sys_net_start(struct m0_addb2_sys *sys)
Definition: sys.c:312
#define out(...)
Definition: gen.c:41
Definition: mutex.h:47
int32_t rc
Definition: trigger_fop.h:47
M0_INTERNAL void m0_mdservice_fsync_fop_fini(void)
Definition: fsync_fops.c:44