Motr  M0
dir.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-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 #include <linux/version.h> /* LINUX_VERSION_CODE */
23 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
24 #include <linux/cred.h>
25 #include <linux/uidgid.h> /* from_kuid */
26 #endif
27 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
28 #include <linux/xattr.h>
29 #endif
30 
31 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_M0T1FS
32 #include "lib/trace.h"
33 
34 #include "lib/misc.h" /* M0_SET0 */
35 #include "lib/memory.h" /* M0_ALLOC_PTR */
36 #include "lib/bob.h"
37 #include "fop/fop.h" /* m0_fop_alloc */
38 #include "rpc/rpclib.h" /* m0_rpc_post_sync */
39 #include "rpc/rpc_opcodes.h"
40 #include "conf/helpers.h" /* m0_confc_root_open */
41 #include "motr/magic.h"
42 #include "layout/layout.h"
43 #include "layout/layout_internal.h" /* LID_NONE */
44 #include "layout/pdclust.h"
47 #include "pool/pool.h"
48 #include "ioservice/fid_convert.h" /* m0_fid_convert_gob2cob */
49 
50 extern const struct m0_uint128 m0_rm_m0t1fs_group;
56 enum {COB_REQ_DEADLINE = 2000000};
57 
58 struct cob_req {
61  struct m0t1fs_sb *cr_csb;
62  int32_t cr_rc;
63  struct m0_fid cr_fid;
64  struct m0_fid cr_pver;
65 };
66 
67 struct cob_fop {
68  struct m0_fop c_fop;
69  struct cob_req *c_req;
70 };
71 
72 static void cob_rpc_item_cb(struct m0_rpc_item *item)
73 {
74  int rc;
75  struct m0_fop *fop;
76  struct cob_fop *cfop;
77  struct cob_req *creq;
78  struct m0_fop_cob_op_reply *reply;
79 
80  M0_PRE(item != NULL);
81 
83  M0_ENTRY("rpc_item %p[%u], item->ri_error %d", item,
85  cfop = container_of(fop, struct cob_fop, c_fop);
86  creq = cfop->c_req;
87 
89  if (rc != 0)
90  goto out;
91 
95 
96  M0_LOG(M0_DEBUG, "%p[%u], item->ri_error %d, reply->cor_rc %d", item,
97  item->ri_type->rit_opcode, item->ri_error, reply->cor_rc);
98  rc = reply->cor_rc;
99 out:
100  if (creq->cr_rc == 0)
101  creq->cr_rc = rc;
102  M0_LOG(M0_DEBUG, "%p[%u] ref %llu, cob_req_fop %p, cr_rc %d, "FID_F,
104  (unsigned long long)m0_ref_read(&fop->f_ref), cfop, creq->cr_rc,
105  FID_P(&creq->cr_fid));
106  m0_semaphore_up(&creq->cr_sem);
107  M0_LEAVE();
108 }
109 
110 static const struct m0_rpc_item_ops cob_item_ops = {
112 };
113 
114 M0_INTERNAL void m0t1fs_inode_bob_init(struct m0t1fs_inode *bob);
115 M0_INTERNAL bool m0t1fs_inode_bob_check(struct m0t1fs_inode *bob);
116 
117 
118 static int file_lock_acquire(struct m0_rm_incoming *rm_in,
119  struct m0t1fs_inode *ci);
120 static void file_lock_release(struct m0_rm_incoming *rm_in);
121 static int m0t1fs_component_objects_op(struct m0t1fs_inode *ci,
122  struct m0t1fs_mdop *mop,
123  int (*func)(struct cob_req *,
124  const struct m0t1fs_inode *,
125  const struct m0t1fs_mdop *,
126  int idx));
127 
128 static int m0t1fs_ios_cob_create(struct cob_req *cr,
129  const struct m0t1fs_inode *inode,
130  const struct m0t1fs_mdop *mop,
131  int idx);
132 
133 static int m0t1fs_ios_cob_delete(struct cob_req *cr,
134  const struct m0t1fs_inode *inode,
135  const struct m0t1fs_mdop *mop,
136  int idx);
137 
138 static int m0t1fs_ios_cob_setattr(struct cob_req *cr,
139  const struct m0t1fs_inode *inode,
140  const struct m0t1fs_mdop *mop,
141  int idx);
142 static int m0t1fs_ios_cob_truncate(struct cob_req *cr,
143  const struct m0t1fs_inode *inode,
144  const struct m0t1fs_mdop *mop,
145  int idx);
146 
147 static int name_mem2wire(struct m0_fop_str *tgt,
148  const struct m0_buf *name)
149 {
150  tgt->s_buf = m0_alloc(name->b_nob);
151  if (tgt->s_buf == NULL)
152  return M0_ERR(-ENOMEM);
153  memcpy(tgt->s_buf, name->b_addr, (int)name->b_nob);
154  tgt->s_len = name->b_nob;
155  return 0;
156 }
157 
158 static void body_mem2wire(struct m0_fop_cob *body,
159  const struct m0_cob_attr *attr,
160  int valid)
161 {
162  body->b_pfid = attr->ca_pfid;
163  body->b_tfid = attr->ca_tfid;
164  if (valid & M0_COB_ATIME)
165  body->b_atime = attr->ca_atime;
166  if (valid & M0_COB_CTIME)
167  body->b_ctime = attr->ca_ctime;
168  if (valid & M0_COB_MTIME)
169  body->b_mtime = attr->ca_mtime;
170  if (valid & M0_COB_BLOCKS)
171  body->b_blocks = attr->ca_blocks;
172  if (valid & M0_COB_SIZE)
173  body->b_size = attr->ca_size;
174  if (valid & M0_COB_MODE)
175  body->b_mode = attr->ca_mode;
176  if (valid & M0_COB_UID)
177  body->b_uid = attr->ca_uid;
178  if (valid & M0_COB_GID)
179  body->b_gid = attr->ca_gid;
180  if (valid & M0_COB_BLOCKS)
181  body->b_blocks = attr->ca_blocks;
182  if (valid & M0_COB_NLINK)
183  body->b_nlink = attr->ca_nlink;
184  if (valid & M0_COB_LID)
185  body->b_lid = attr->ca_lid;
186  if (valid & M0_COB_PVER)
187  body->b_pver = attr->ca_pver;
188  body->b_valid = valid;
189 }
190 
191 static void body_wire2mem(struct m0_cob_attr *attr,
192  const struct m0_fop_cob *body)
193 {
194  M0_SET0(attr);
195  attr->ca_pfid = body->b_pfid;
196  attr->ca_tfid = body->b_tfid;
197  attr->ca_valid = body->b_valid;
198  if (body->b_valid & M0_COB_MODE)
199  attr->ca_mode = body->b_mode;
200  if (body->b_valid & M0_COB_UID)
201  attr->ca_uid = body->b_uid;
202  if (body->b_valid & M0_COB_GID)
203  attr->ca_gid = body->b_gid;
204  if (body->b_valid & M0_COB_ATIME)
205  attr->ca_atime = body->b_atime;
206  if (body->b_valid & M0_COB_MTIME)
207  attr->ca_mtime = body->b_mtime;
208  if (body->b_valid & M0_COB_CTIME)
209  attr->ca_ctime = body->b_ctime;
210  if (body->b_valid & M0_COB_NLINK)
211  attr->ca_nlink = body->b_nlink;
212  if (body->b_valid & M0_COB_RDEV)
213  attr->ca_rdev = body->b_rdev;
214  if (body->b_valid & M0_COB_SIZE)
215  attr->ca_size = body->b_size;
216  if (body->b_valid & M0_COB_BLKSIZE)
217  attr->ca_blksize = body->b_blksize;
218  if (body->b_valid & M0_COB_BLOCKS)
219  attr->ca_blocks = body->b_blocks;
220  if (body->b_valid & M0_COB_LID)
221  attr->ca_lid = body->b_lid;
222  if (body->b_valid & M0_COB_PVER)
223  attr->ca_pver = body->b_pver;
224  attr->ca_version = body->b_version;
225 }
226 
227 M0_INTERNAL int m0t1fs_fs_conf_lock(struct m0t1fs_sb *csb)
228 {
229  int rc;
230 
231  M0_ENTRY("csb=%p", csb);
233  if (rc != 0)
234  return M0_ERR(rc);
236  return M0_RC(0);
237 }
238 
239 M0_INTERNAL void m0t1fs_fs_conf_unlock(struct m0t1fs_sb *csb)
240 {
243 }
252 void m0t1fs_fid_alloc(struct m0t1fs_sb *csb, struct m0_fid *out)
253 {
255 
256  m0_fid_set(out, 0, csb->csb_next_key++);
257 
258  M0_LOG(M0_DEBUG, "fid "FID_F, FID_P(out));
259 }
260 
265 void m0t1fs_fid_accept(struct m0t1fs_sb *csb, const struct m0_fid *fid)
266 {
268 
269  csb->csb_next_key = max64(csb->csb_next_key, fid->f_key + 1);
270 }
271 
272 int m0t1fs_inode_set_layout_id(struct m0t1fs_inode *ci,
273  struct m0t1fs_mdop *mo,
274  int layout_id)
275 {
276  struct m0t1fs_sb *csb = M0T1FS_SB(ci->ci_inode.i_sb);
277  struct m0_fop *rep_fop = NULL;
278  int rc;
279 
280  /*
281  * Layout can be changed only for the freshly
282  * created file which does not contain any data yet.
283  */
284  if (ci->ci_inode.i_size != 0) {
285  rc = -EEXIST;
286  return rc;
287  }
288 
289  if (layout_id == LID_NONE) {
290  rc = -EINVAL;
291  return rc;
292  }
293 
294  if (layout_id == ci->ci_layout_id)
295  return 0;
296 
297  ci->ci_layout_id = layout_id;
298 
300  if (rc != 0)
301  return rc;
302 
303  mo->mo_attr.ca_lid = ci->ci_layout_id;
304  mo->mo_attr.ca_valid |= M0_COB_LID;
305 
306  if (!csb->csb_oostore) {
309  goto out;
310  }
311  M0_LOG(M0_DEBUG, "Changing lid to %lld", mo->mo_attr.ca_lid);
313 out:
314  if (rc == 0)
315  ci->ci_layout_changed = true;
316  return rc;
317 }
318 
319 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
320 int m0t1fs_setxattr(const struct xattr_handler *handler,
321  struct dentry *dentry, struct inode *inode,
322  const char *name, const void *value,
323  size_t size, int flags)
324 #else
325 int m0t1fs_setxattr(struct dentry *dentry, const char *name,
326  const void *value, size_t size, int flags)
327 #endif
328 {
329  struct m0t1fs_inode *ci = M0T1FS_I(dentry->d_inode);
330  struct m0t1fs_sb *csb = M0T1FS_SB(ci->ci_inode.i_sb);
332  struct m0t1fs_mdop mo;
333  int rc;
334  struct m0_fop *rep_fop = NULL;
335 
337 
338 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
339  /*
340  * XXX: this is for oostore objects whose xattr name
341  * is empty here (for some reason, I could not figure out why).
342  * Interesting that in normal (non-oostore) mode it works fine.
343  */
344  name = handler->name;
345 #endif
346  M0_ENTRY("Setting %.*s's xattr %s=%.*s", dentry->d_name.len,
347  (char*)dentry->d_name.name, name, (int)size, (char *)value);
348 
349 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
350  if (value == NULL)
351  return m0t1fs_removexattr(dentry, name);
352 #endif
354  if (rc != 0)
355  return M0_ERR(rc);
356  M0_SET0(&mo);
357  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
358  m0_buf_init(&mo.mo_attr.ca_name, (char*)dentry->d_name.name,
359  dentry->d_name.len);
360  mo.mo_attr.ca_pver = ci->ci_pver;
361 
362  if (m0_streq(name, "lid")) {
363  char *endp;
364  char buf[40];
365 
366  rc = -EINVAL;
367  if (value == NULL || size >= ARRAY_SIZE(buf))
368  goto out;
369  memcpy(buf, value, size);
370  buf[size] = '\0';
371  layout_id = simple_strtoul(buf, &endp, 0);
372  if (endp - buf < size || layout_id == LID_NONE)
373  goto out;
374 
376  if (rc != 0)
377  goto out;
378  } else if (m0_streq(name, "writesize")) {
379  /* parse `single_write_size[;total_file_size]' value(s) */
380  /* TODO: total_file_size is not used yet */
381  size_t buffsize = 0;
382  size_t filesize = 0;
383  char *bsptr, *wsptr, *endp;
384  char buf[40], *ptr;
385 
386  rc = -EINVAL;
387  if (value == NULL || size >= ARRAY_SIZE(buf))
388  goto out;
389 
390  memcpy(buf, value, size);
391  buf[size] = '\0';
392  ptr = buf;
393 
394  bsptr = strsep(&ptr, ";");
395  if (bsptr != NULL)
396  buffsize = simple_strtoul(bsptr, &endp, 0);
397  M0_LOG(M0_DEBUG, "New IO buffsize: %d.", (int)buffsize);
398 
399  wsptr = strsep(&ptr, ";");
400  if (wsptr != NULL) {
401  filesize = simple_strtoul(wsptr, &endp, 0);
402  M0_LOG(M0_DEBUG, "Total IO size: %d.", (int)filesize);
403  }
404 
405  /* Find optimal lid and set it to the inode.*/
406  layout_id = m0_layout_find_by_buffsize(&csb->csb_reqh.rh_ldom,
407  &ci->ci_pver, buffsize);
408  if (layout_id > 0)
410  else
411  rc = M0_ERR_INFO(layout_id, "Could not find layout_id: "
412  "rc=%d", layout_id);
413  } else {
414  if (csb->csb_oostore) {
415  rc = -EOPNOTSUPP;
416  goto out;
417  }
418  m0_buf_init(&mo.mo_attr.ca_eakey, (void*)name, strlen(name));
419  m0_buf_init(&mo.mo_attr.ca_eaval, (void*)value, size);
422  }
423 out:
425  return M0_RC(rc);
426 }
427 
428 
429 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
430 int m0t1fs_fid_getxattr(const struct xattr_handler *handler,
431  struct dentry *dentry, struct inode *inode,
432  const char *name, void *buffer,
433  size_t size)
434 #else
435 ssize_t m0t1fs_fid_getxattr(struct dentry *dentry, const char *name,
436  void *buffer, size_t size)
437 #endif
438 {
440  return M0_ERR(-EOPNOTSUPP);
441 }
442 
443 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
444 int m0t1fs_getxattr(const struct xattr_handler *handler,
445  struct dentry *dentry, struct inode *inode,
446  const char *name, void *buffer,
447  size_t size)
448 #else
449 ssize_t m0t1fs_getxattr(struct dentry *dentry, const char *name,
450  void *buffer, size_t size)
451 #endif
452 {
453  struct m0t1fs_inode *ci = M0T1FS_I(dentry->d_inode);
454  struct m0t1fs_sb *csb = M0T1FS_SB(ci->ci_inode.i_sb);
456  struct m0t1fs_mdop mo;
457  int rc;
458  struct m0_fop *rep_fop = NULL;
460 
461 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
462  /* XXX: see comment for the same code above at m0t1fs_setxattr(). */
463  name = handler->name;
464 #endif
465  M0_ENTRY("Getting %.*s's xattr %s", dentry->d_name.len,
466  (char*)dentry->d_name.name, name);
468  if (rc != 0)
469  return M0_ERR(rc);
470  if (m0_streq(name, "pver")) {
471  M0_LOG(M0_DEBUG, "buffer:%p size:%d"FID_F, buffer, (int)size,
472  FID_P(&ci->ci_pver));
473  if (buffer != NULL) {
474  if ((size_t)sizeof(struct m0_fid) > size) {
475  rc = M0_ERR(-ERANGE);
476  goto out;
477  }
478  sprintf(buffer, FID_F, FID_P(&ci->ci_pver));
479  rc = strlen(buffer);
480  goto out;
481  }
482  rc = M0_FID_STR_LEN;
483  goto out;
484  }
485  if (m0_streq(name, "lid")) {
486  M0_LOG(M0_DEBUG, "buffer:%p size:%d lid:%d"FID_F, buffer,
487  (int)size, (int)ci->ci_layout_id,
488  FID_P(&ci->ci_pver));
489  if (buffer != NULL) {
490  if ((size_t)sizeof(uint64_t) > size) {
491  rc = M0_ERR(-ERANGE);
492  goto out;
493  }
494  sprintf(buffer, "%d", (int)ci->ci_layout_id);
495  rc = strlen(buffer);
496  goto out;
497  }
498  rc = UINT32_STR_LEN;
499  goto out;
500  }
501  if (csb->csb_oostore) {
502  rc = M0_ERR(-EOPNOTSUPP);
503  goto out;
504  }
505 
506  M0_SET0(&mo);
507  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
508  m0_buf_init(&mo.mo_attr.ca_name, (char*)dentry->d_name.name,
509  dentry->d_name.len);
510  m0_buf_init(&mo.mo_attr.ca_eakey, (char*)name, strlen(name));
511  mo.mo_attr.ca_pver = ci->ci_pver;
512 
514  if (rc == 0) {
516  if (buffer != NULL) {
517  if ((size_t)rep->g_value.s_len > size) {
518  rc = M0_ERR(-ERANGE);
519  goto out;
520  }
521  memcpy(buffer, rep->g_value.s_buf, rep->g_value.s_len);
522  }
523  rc = rep->g_value.s_len; /* return xattr length */
524  } else if (rc == -ENOENT)
525  rc = M0_ERR(-ENODATA);
526 out:
529  return M0_RC(rc);
530 }
531 
532 ssize_t m0t1fs_fid_listxattr(struct dentry *dentry, char *buffer, size_t size)
533 {
535  return M0_ERR(-EOPNOTSUPP);
536 }
537 
538 ssize_t m0t1fs_listxattr(struct dentry *dentry, char *buffer, size_t size)
539 {
541  return M0_ERR(-EOPNOTSUPP);
542 }
543 
544 int m0t1fs_fid_removexattr(struct dentry *dentry, const char *name)
545 {
547  return M0_ERR(-EOPNOTSUPP);
548 }
549 
550 int m0t1fs_removexattr(struct dentry *dentry, const char *name)
551 {
552  struct m0t1fs_inode *ci = M0T1FS_I(dentry->d_inode);
553  struct m0t1fs_sb *csb = M0T1FS_SB(ci->ci_inode.i_sb);
554  struct m0t1fs_mdop mo;
555  int rc;
556  struct m0_fop *rep_fop;
557 
559  M0_ENTRY("Deleting %.*s's xattr %s", dentry->d_name.len,
560  (char*)dentry->d_name.name, name);
561 
562  if (csb->csb_oostore)
563  return M0_RC(-EOPNOTSUPP);
565  if (rc != 0)
566  return M0_ERR(rc);
567 
568  M0_SET0(&mo);
569  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
570  m0_buf_init(&mo.mo_attr.ca_name, (char*)dentry->d_name.name,
571  dentry->d_name.len);
572  m0_buf_init(&mo.mo_attr.ca_eakey, (char*)name, strlen(name));
573 
575  if (rc == -ENOENT)
576  rc = M0_ERR(-ENODATA);
579  return M0_RC(rc);
580 }
581 
582 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
583 static int m0t1fs_fid_create(struct inode *dir,
584  struct dentry *dentry,
585  umode_t mode,
586  bool excl)
587 #else
588 static int m0t1fs_fid_create(struct inode *dir,
589  struct dentry *dentry,
590  int mode,
591  struct nameidata *nd)
592 #endif
593 {
594  return M0_ERR(-EOPNOTSUPP);
595 }
596 
597 static int m0t1fs_fid_check(struct m0_fid *fid)
598 {
599  if ((fid->f_container & ~M0_FID_GOB_CONTAINER_MASK) != 0) {
600  M0_LOG(M0_ERROR, "Invalid gob fid detected: "FID_F". Container "
601  "component should not be longer than 32bit.",
602  FID_P(fid));
603  return -EINVAL;
604  }
605  return 0;
606 }
607 
608 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
609 static int m0t1fs_create(struct inode *dir,
610  struct dentry *dentry,
611  umode_t mode,
612  bool excl)
613 #else
614 static int m0t1fs_create(struct inode *dir,
615  struct dentry *dentry,
616  int mode,
617  struct nameidata *nd)
618 #endif
619 {
620  struct super_block *sb = dir->i_sb;
621  struct m0t1fs_sb *csb = M0T1FS_SB(sb);
622  struct m0t1fs_inode *ci;
623  struct m0t1fs_mdop mo;
624  struct inode *inode;
625  struct m0_fid new_fid;
626  struct m0_fid gfid;
627  int rc;
628  struct m0_fop *rep_fop = NULL;
630  bool i_err = false;
631 
633  M0_ENTRY();
634 
635  M0_LOG(M0_DEBUG, "Creating \"%s\" in pdir %lu "FID_F,
636  (char*)dentry->d_name.name, dir->i_ino,
637  FID_P(m0t1fs_inode_fid(M0T1FS_I(dir))));
638 
640  if (rc != 0)
641  return M0_ERR(rc);
642  rc = m0_pool_version_get(&csb->csb_pools_common, NULL, &pv);
643  if (rc != 0)
644  goto out;
645 
646  inode = new_inode(sb);
647  if (inode == NULL) {
648  rc = M0_ERR(-ENOMEM);
649  goto out;
650  }
651  if (csb->csb_oostore) {
652  rc = m0_fid_sscanf(dentry->d_name.name, &new_fid);
653  if (rc != 0) {
654  M0_LOG(M0_ERROR, "Cannot parse fid \"%s\" in oostore",
655  (char*)dentry->d_name.name);
656  i_err = true;
657  goto out;
658  }
659  } else {
661  }
663  if (rc != 0) {
664  i_err = true;
665  goto out;
666  }
667 
669  M0_LOG(M0_DEBUG, "New fid = "FID_F, FID_P(&new_fid));
670  inode->i_ino = m0_fid_hash(&gfid);
671  ci = M0T1FS_I(inode);
672  ci->ci_fid = gfid;
673 
674  inode->i_mode = mode;
675  inode->i_uid = current_fsuid();
676  if (dir->i_mode & S_ISGID) {
677  inode->i_gid = dir->i_gid;
678  if (S_ISDIR(mode))
679  inode->i_mode |= S_ISGID;
680  } else
681  inode->i_gid = current_fsgid();
682 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
683  inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
684 #else
685  inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
686 #endif
687  inode->i_blocks = 0;
688  if (S_ISDIR(mode)) {
691  inc_nlink(inode); /* one more link (".") for directories */
692  } else {
695  inode->i_mapping->a_ops = &m0t1fs_aops;
696  }
697 
698  ci->ci_pver = pv->pv_id;
699  M0_LOG(M0_INFO, "Creating \"%s\" with pool version "FID_F,
700  (char*)dentry->d_name.name, FID_P(&ci->ci_pver));
701  /* layout id for new file */
702  ci->ci_layout_id = M0_DEFAULT_LAYOUT_ID;
703 
706  if (rc != 0) {
707  i_err = true;
708  goto out;
709  }
710 
711  M0_SET0(&mo);
712 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
713  mo.mo_attr.ca_uid = from_kuid(current_user_ns(), inode->i_uid);
714  mo.mo_attr.ca_gid = from_kgid(current_user_ns(), inode->i_gid);
715 #else
716  mo.mo_attr.ca_uid = inode->i_uid;
717  mo.mo_attr.ca_gid = inode->i_gid;
718 #endif
719  mo.mo_attr.ca_atime = inode->i_atime.tv_sec;
720  mo.mo_attr.ca_ctime = inode->i_ctime.tv_sec;
721  mo.mo_attr.ca_mtime = inode->i_mtime.tv_sec;
722  mo.mo_attr.ca_mode = inode->i_mode;
723  mo.mo_attr.ca_blocks = inode->i_blocks;
724  mo.mo_attr.ca_pfid = *m0t1fs_inode_fid(M0T1FS_I(dir));
725  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
726  mo.mo_attr.ca_pver = ci->ci_pver;
727  mo.mo_attr.ca_lid = ci->ci_layout_id;
728  mo.mo_attr.ca_nlink = inode->i_nlink;
729  mo.mo_attr.ca_valid = (M0_COB_UID | M0_COB_GID | M0_COB_ATIME |
733  m0_buf_init(&mo.mo_attr.ca_name, (char*)dentry->d_name.name,
734  dentry->d_name.len);
735 
736  if (!csb->csb_oostore) {
738  if (rc != 0) {
739  i_err = true;
740  goto out;
741  }
742  }
743  if (S_ISREG(mode) && csb->csb_oostore) {
745  if (rc != 0) {
746  i_err = true;
747  goto out;
748  }
749  }
750 
751  if (insert_inode_locked4(inode, inode->i_ino,
752  &m0t1fs_inode_test, &gfid) < 0) {
753  M0_LOG(M0_ERROR, "Duplicate inode: "FID_F, FID_P(&gfid));
754  rc = M0_ERR(-EIO);
755  i_err = true;
756  goto out;
757  }
758  m0_mutex_lock(&csb->csb_inodes_lock);
759  csb_inodes_tlist_add_tail(&csb->csb_inodes, ci);
760  m0_mutex_unlock(&csb->csb_inodes_lock);
764 
765 out:
768  if (i_err) {
769  clear_nlink(inode);
770  make_bad_inode(inode);
771  iput(inode);
772  }
775  return M0_RC(rc);
776 }
777 
778 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
779 static int m0t1fs_fid_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
780 #else
781 static int m0t1fs_fid_mkdir(struct inode *dir, struct dentry *dentry, int mode)
782 #endif
783 {
785  return m0t1fs_fid_create(dir, dentry, mode | S_IFDIR, NULL);
786 }
787 
788 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
789 static int m0t1fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
790 #else
791 static int m0t1fs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
792 #endif
793 {
795  return m0t1fs_create(dir, dentry, mode | S_IFDIR, NULL);
796 }
797 
798 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
799 static struct dentry *m0t1fs_lookup(struct inode *dir,
800  struct dentry *dentry,
801  unsigned int flags)
802 #else
803 static struct dentry *m0t1fs_lookup(struct inode *dir,
804  struct dentry *dentry,
805  struct nameidata *nd)
806 #endif
807 {
808  struct m0t1fs_sb *csb;
809  struct inode *inode = NULL;
810  struct m0_fop_lookup_rep *rep = NULL;
811  struct m0t1fs_mdop mo;
812  int rc;
813  void *err_ptr = NULL;
814  struct m0_fop *rep_fop = NULL;
815  bool dcache_splice = false;
816  bool i_err = false;
817 
819  M0_ENTRY();
820 
822  csb = M0T1FS_SB(dir->i_sb);
823 
824  if (dentry->d_name.len > csb->csb_namelen) {
825  M0_LEAVE("ERR_PTR: %p", ERR_PTR(-ENAMETOOLONG));
826  return ERR_PTR(-ENAMETOOLONG);
827  }
828 
829  M0_LOG(M0_INFO, "Name: \"%s\"", (char*)dentry->d_name.name);
831  if (rc != 0)
832  return ERR_PTR(rc);
833  if (csb->csb_oostore) {
834  struct m0_fid new_fid;
835  struct m0_fid gfid;
836  struct m0_fop_cob body;
837  struct m0_pool_version *pv;
838 
839  rc = m0_fid_sscanf(dentry->d_name.name, &new_fid);
840  if (rc != 0) {
841  M0_LOG(M0_ERROR, "Cannot parse fid \"%s\" in oostore",
842  (char*)dentry->d_name.name);
843  err_ptr = ERR_PTR(-EINVAL);
844  goto out;
845  }
847  if (rc != 0) {
848  err_ptr = ERR_PTR(-EINVAL);
849  goto out;
850  }
853  body.b_lid = M0_DEFAULT_LAYOUT_ID;
854  body.b_mode = S_IFREG;
855  rc = m0_pool_version_get(&csb->csb_pools_common, NULL, &pv);
856  if (rc != 0) {
857  M0_LEAVE("ERROR: rc:%d", rc);
858  err_ptr = ERR_PTR(rc);
859  goto out;
860  }
861  body.b_pver = pv->pv_id;
862  inode = m0t1fs_iget(dir->i_sb, &gfid, &body);
863  if (IS_ERR(inode)) {
864  M0_LEAVE("ERROR: %p", ERR_CAST(inode));
865  err_ptr = ERR_CAST(inode);
866  goto out;
867  }
869  if (rc != 0) {
870  M0_LEAVE("rc:%d", rc);
871  i_err = true;
872  goto out;
873  }
874  dcache_splice = true;
875  goto out;
876  }
877 
878  M0_SET0(&mo);
879  mo.mo_attr.ca_pfid = *m0t1fs_inode_fid(M0T1FS_I(dir));
880  m0_buf_init(&mo.mo_attr.ca_name, (char*)dentry->d_name.name,
881  dentry->d_name.len);
883  if (rc != 0) {
884  M0_LEAVE("rc:%d", rc);
885  goto out;
886  }
888  mo.mo_attr.ca_tfid = rep->l_body.b_tfid;
889  inode = m0t1fs_iget(dir->i_sb, &mo.mo_attr.ca_tfid,
890  &rep->l_body);
891  if (IS_ERR(inode)) {
892  M0_LEAVE("ERROR: %p", ERR_CAST(inode));
893  err_ptr = ERR_CAST(inode);
894  goto out;
895  }
896  dcache_splice = true;
897 out:
900  if (i_err) {
901  make_bad_inode(inode);
902  iput(inode);
903  }
904  M0_LEAVE();
905 
906  return dcache_splice ? d_splice_alias(inode, dentry) : err_ptr;
907 }
908 
909 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
910 static struct dentry *m0t1fs_fid_lookup(struct inode *dir,
911  struct dentry *dentry,
912  unsigned int flags)
913 #else
914 static struct dentry *m0t1fs_fid_lookup(struct inode *dir,
915  struct dentry *dentry,
916  struct nameidata *nd)
917 #endif
918 {
919  struct m0_fid fid;
920  int rc;
921 
923  rc = m0_fid_sscanf(dentry->d_name.name, &fid);
924  if (rc != 0) {
925  M0_LEAVE("Cannot parse fid \"%s\"", (char*)dentry->d_name.name);
926  return ERR_PTR(rc);
927  }
929 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
930  return m0t1fs_lookup(dir, dentry, flags);
931 #else
932  return m0t1fs_lookup(dir, dentry, nd);
933 #endif
934 }
935 
936 
938 {
939  struct m0_dirent *dent = NULL;
940 
941  if (ent->d_reclen > 0)
942  dent = (struct m0_dirent *)((char*)ent + ent->d_reclen);
943 
944  return dent;
945 }
946 
948 {
949  struct m0_dirent *ent = (struct m0_dirent *)rep->r_buf.b_addr;
950  return ent->d_namelen > 0 ? ent : NULL;
951 }
952 
953 static int m0t1fs_opendir(struct inode *inode, struct file *file)
954 {
955  struct m0t1fs_filedata *fd;
957  M0_ENTRY();
958 
959  M0_ALLOC_PTR(fd);
960  if (fd == NULL)
961  return M0_ERR(-ENOMEM);
962  file->private_data = fd;
963 
965  fd->fd_dirpos = m0_alloc(M0T1FS_SB(inode->i_sb)->csb_namelen);
966  if (fd->fd_dirpos == NULL) {
967  m0_free(fd);
968  return M0_ERR(-ENOMEM);
969  }
970  m0_bitstring_copy(fd->fd_dirpos, ".", 1);
971  fd->fd_direof = 0;
972  fd->fd_mds_index = 0;
973  return 0;
974 }
975 
976 static int m0t1fs_fid_opendir(struct inode *inode, struct file *file)
977 {
979  return m0t1fs_opendir(inode, file);
980 }
981 
982 static int m0t1fs_releasedir(struct inode *inode, struct file *file)
983 {
984  struct m0t1fs_filedata *fd = file->private_data;
986  M0_ENTRY();
987 
988  m0_free(fd->fd_dirpos);
989  m0_free0(&file->private_data);
990  return 0;
991 }
992 
993 static int m0t1fs_fid_releasedir(struct inode *inode, struct file *file)
994 {
996  return m0t1fs_releasedir(inode, file);
997 }
998 
999 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
1000 static int m0t1fs_fid_readdir(struct file *f, struct dir_context *ctx)
1001 {
1003  return M0_RC(0);
1004 }
1005 #else
1006 static int m0t1fs_fid_readdir(struct file *f,
1007  void *buf,
1008  filldir_t filldir)
1009 {
1011  return M0_RC(0);
1012 }
1013 #endif
1014 
1015 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
1016 static int m0t1fs_readdir(struct file *f, struct dir_context *ctx)
1017 #else
1018 static int m0t1fs_readdir(struct file *f,
1019  void *buf,
1020  filldir_t filldir)
1021 #endif
1023  struct m0t1fs_inode *ci;
1024  struct m0t1fs_mdop mo;
1025  struct m0t1fs_sb *csb;
1026  struct m0_fop_readdir_rep *rep;
1027  struct dentry *dentry;
1028  struct inode *dir;
1029  struct m0_dirent *ent;
1030  struct m0t1fs_filedata *fd;
1031  int type;
1032  ino_t ino;
1033  int i;
1034  int rc;
1035  int over;
1036  bool dot_filled = false;
1037  bool dotdot_filled = false;
1038  struct m0_fop *rep_fop;
1039 
1041  M0_ENTRY();
1042 
1043  dentry = f->f_path.dentry;
1044  dir = dentry->d_inode;
1045  ci = M0T1FS_I(dir);
1046  csb = M0T1FS_SB(dir->i_sb);
1047 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
1048  i = ctx->pos;
1049 #else
1050  i = f->f_pos;
1051 #endif
1052 
1053  if (csb->csb_oostore)
1054  return M0_RC(0);
1055  fd = f->private_data;
1056  if (fd->fd_direof)
1057  return M0_RC(0);
1058 
1060  if (rc != 0)
1061  return M0_ERR(rc);
1062 
1063 switch_mds:
1064  M0_SET0(&mo);
1071  m0_buf_init(&mo.mo_attr.ca_name, m0_bitstring_buf_get(fd->fd_dirpos),
1072  m0_bitstring_len_get(fd->fd_dirpos));
1073  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
1074  mo.mo_use_hint = true;
1075  mo.mo_hash_hint = fd->fd_mds_index;
1076 
1077  do {
1078  M0_LOG(M0_DEBUG, "readdir from position \"%*s\"@ mds%d",
1079  (int)mo.mo_attr.ca_name.b_nob,
1080  (char *)mo.mo_attr.ca_name.b_addr,
1081  mo.mo_hash_hint);
1082 
1084  rep = m0_fop_data(rep_fop);
1085  if (rc < 0) {
1086  M0_LOG(M0_ERROR,
1087  "Failed to read dir from pos \"%*s\". Error %d",
1088  (int)mo.mo_attr.ca_name.b_nob,
1089  (char *)mo.mo_attr.ca_name.b_addr, rc);
1090  goto out;
1091  }
1092 
1093  for (ent = dirent_first(rep); ent != NULL;
1094  ent = dirent_next(ent)) {
1095  if (ent->d_namelen == 1 &&
1096  memcmp(ent->d_name, ".", 1) == 0) {
1097  if (dot_filled)
1098  continue;
1099  ino = dir->i_ino;
1100  type = DT_DIR;
1101  dot_filled = true;
1102  } else if (ent->d_namelen == 2 &&
1103  memcmp(ent->d_name, "..", 2) == 0) {
1104  if (dotdot_filled)
1105  continue;
1106  ino = parent_ino(dentry);
1107  type = DT_DIR;
1108  dotdot_filled = true;
1109  } else {
1114  ino = ++i;
1115  type = DT_UNKNOWN;
1116  }
1117 
1118  M0_LOG(M0_DEBUG, "filled off %lu ino %lu name"
1119  " \"%.*s\", ino %lu, type %d",
1120  (unsigned long)f->f_pos, (unsigned long)ino,
1121  ent->d_namelen, (char *)ent->d_name,
1122  ino, type);
1123 
1124 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
1125  over = dir_emit(ctx, ent->d_name, ent->d_namelen,
1126  ino, type);
1127  if (!over) {
1128  rc = 0;
1129  M0_LOG(M0_DEBUG, "full");
1130  goto out;
1131  }
1132  ctx->pos++;
1133 #else
1135  f->f_pos, ino, type);
1136  if (over) {
1137  rc = 0;
1138  M0_LOG(M0_DEBUG, "full");
1139  goto out;
1140  }
1141  f->f_pos++;
1142 #endif
1143  }
1144  m0_bitstring_copy(fd->fd_dirpos, rep->r_end.s_buf,
1145  rep->r_end.s_len);
1146  m0_buf_init(&mo.mo_attr.ca_name,
1147  m0_bitstring_buf_get(fd->fd_dirpos),
1148  m0_bitstring_len_get(fd->fd_dirpos));
1149 
1150  M0_LOG(M0_DEBUG, "set position to \"%*s\" rc == %d",
1151  (int)mo.mo_attr.ca_name.b_nob,
1152  (char *)mo.mo_attr.ca_name.b_addr, rc);
1154  /*
1155  * Return codes for m0t1fs_mds_cob_readdir() are the following:
1156  * - <0 - some error occured;
1157  * - >0 - EOF signaled by mdservice, some number of entries
1158  * available;
1159  * - 0 - no error, some number of entries is sent by mdservice.
1160  */
1161  } while (rc == 0);
1162  /*
1163  * EOF from one mdservice is detected. Switch to another mds.
1164  */
1165  if (++fd->fd_mds_index < csb->csb_pools_common.pc_nr_svcs[M0_CST_MDS]) {
1166  m0_bitstring_copy(fd->fd_dirpos, ".", 1);
1167  M0_LOG(M0_DEBUG, "switch to mds %d", fd->fd_mds_index);
1168  goto switch_mds;
1169  }
1170 
1171  /*
1172  * EOF detected from all mds. Set return code to 0 to make vfs happy.
1173  */
1174  fd->fd_direof = 1;
1175  rc = 0;
1176 out:
1177  if (rc != 0)
1180  return M0_RC(rc);
1181 }
1182 
1183 static int m0t1fs_fid_link(struct dentry *old, struct inode *dir,
1184  struct dentry *new)
1185 {
1187  return M0_ERR(-EOPNOTSUPP);
1188 }
1189 
1190 static int m0t1fs_link(struct dentry *old, struct inode *dir,
1191  struct dentry *new)
1192 {
1193  struct m0t1fs_sb *csb;
1194  struct m0t1fs_mdop mo;
1195  struct m0t1fs_inode *ci;
1196  struct inode *inode = old->d_inode;
1197 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
1198  struct timespec64 now = current_time(inode);
1199 #else
1200  struct timespec now = CURRENT_TIME_SEC;
1201 #endif
1202  int rc;
1203  struct m0_fop *rep_fop;
1204 
1206  /*
1207  * file -> mds is mapped by hash of filename.
1208  * Link will create a new file entry in dir, but object may
1209  * be on another mds. So link is disabled until this problem is solved.
1210  */
1211  return M0_ERR(-EOPNOTSUPP);
1212 
1213  ci = M0T1FS_I(inode);
1214  csb = M0T1FS_SB(inode->i_sb);
1215 
1217  if (rc != 0)
1218  return M0_ERR(rc);
1219 
1220  M0_SET0(&mo);
1221  mo.mo_attr.ca_pfid = *m0t1fs_inode_fid(M0T1FS_I(dir));
1222  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
1223  mo.mo_attr.ca_nlink = inode->i_nlink + 1;
1224  mo.mo_attr.ca_ctime = now.tv_sec;
1225  mo.mo_attr.ca_valid = (M0_COB_CTIME | M0_COB_NLINK);
1226  m0_buf_init(&mo.mo_attr.ca_name, (char*)new->d_name.name,
1227  new->d_name.len);
1228 
1230  if (rc != 0) {
1231  M0_LOG(M0_ERROR, "mdservive link fop failed: %d", rc);
1232  goto out;
1233  }
1234 
1235  inode_inc_link_count(inode);
1236  inode->i_ctime = now;
1237  atomic_inc(&inode->i_count);
1238  d_instantiate(new, inode);
1240 
1241 out:
1244  return M0_RC(rc);
1245 }
1246 
1247 static int m0t1fs_fid_unlink(struct inode *dir, struct dentry *dentry)
1248 {
1250  return M0_ERR(-EOPNOTSUPP);
1251 }
1252 
1253 static int m0t1fs_unlink(struct inode *dir, struct dentry *dentry)
1254 {
1255  struct m0t1fs_sb *csb;
1256  struct inode *inode;
1257  struct m0t1fs_inode *ci;
1258  struct m0t1fs_mdop mo;
1259 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
1260  struct timespec64 now;
1261 #else
1262  struct timespec now;
1263 #endif
1264  int rc = 0;
1265  struct m0_fop *lookup_rep_fop = NULL;
1266  struct m0_fop *unlink_rep_fop = NULL;
1267  struct m0_fop *setattr_rep_fop = NULL;
1268 
1270  M0_ENTRY();
1271 
1272  M0_LOG(M0_INFO, "Name: \"%s\"", (char*)dentry->d_name.name);
1273 
1274  inode = dentry->d_inode;
1275  csb = M0T1FS_SB(inode->i_sb);
1276  ci = M0T1FS_I(inode);
1277 
1279  if (rc != 0)
1280  return M0_ERR(rc);
1281 
1282  M0_SET0(&mo);
1283 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
1284  now = current_time(inode);
1285 #else
1286  now = CURRENT_TIME_SEC;
1287 #endif
1288  mo.mo_attr.ca_pfid = *m0t1fs_inode_fid(M0T1FS_I(dir));
1289  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
1290  mo.mo_attr.ca_nlink = inode->i_nlink - 1;
1291  mo.mo_attr.ca_ctime = now.tv_sec;
1292  mo.mo_attr.ca_valid = (M0_COB_NLINK | M0_COB_CTIME);
1293  m0_buf_init(&mo.mo_attr.ca_name,
1294  (char*)dentry->d_name.name, dentry->d_name.len);
1295  mo.mo_attr.ca_pver = ci->ci_pver;
1296 
1297  if (csb->csb_oostore) {
1300  if (rc == 0) {
1301  inode->i_ctime = dir->i_ctime = dir->i_mtime = now;
1302  inode_dec_link_count(inode);
1304  } else
1305  M0_LOG(M0_ERROR,
1306  "ioservice delete fop failed: %d, gob fid "
1307  FID_F", size=%lld",
1309  ci->ci_inode.i_size);
1310  goto out;
1311  }
1312 
1313  rc = m0t1fs_mds_cob_lookup(csb, &mo, &lookup_rep_fop);
1314  if (rc != 0)
1315  goto out;
1316 
1317  /* @todo: According to MM, a hash function will be used to choose
1318  * a list of extra ioservices, on which "meta component objects" will
1319  * be created. For unlink, it is similar to that:
1320  * rc = m0t1fs_component_objects_op(ci, &mo, m0t1fs_ios_cob_delete);
1321  * That will be done in separated MM tasks.
1322  */
1323  rc = m0t1fs_mds_cob_unlink(csb, &mo, &unlink_rep_fop);
1324  if (rc != 0) {
1325  M0_LOG(M0_ERROR, "mdservive unlink fop failed: %d", rc);
1326  goto out;
1327  }
1328 
1329  /*
1330  * IOS cob may not yet created. So skip deletion of
1331  * ios cob if file size is zero.
1332  */
1333  if (mo.mo_attr.ca_nlink == 0 && ci->ci_inode.i_size > 0) {
1335  if (rc != 0) {
1336  M0_LOG(M0_ERROR, "ioservice delete fop failed: %d", rc);
1337  goto out;
1338  }
1339  }
1340 
1342  M0_SET0(&mo);
1343  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(M0T1FS_I(dir));
1344  mo.mo_attr.ca_ctime = now.tv_sec;
1345  mo.mo_attr.ca_mtime = now.tv_sec;
1346  mo.mo_attr.ca_valid = (M0_COB_CTIME | M0_COB_MTIME);
1347  m0_buf_init(&mo.mo_attr.ca_name,
1348  (char*)dentry->d_name.name, dentry->d_name.len);
1349  mo.mo_attr.ca_pver = ci->ci_pver;
1350 
1351  rc = m0t1fs_mds_cob_setattr(csb, &mo, &setattr_rep_fop);
1352  if (rc != 0) {
1353  M0_LOG(M0_ERROR, "Setattr on parent dir failed with %d", rc);
1354  goto out;
1355  }
1356 
1357  inode->i_ctime = dir->i_ctime = dir->i_mtime = now;
1358  inode_dec_link_count(inode);
1360 out:
1361  m0_fop_put0_lock(lookup_rep_fop);
1362  m0_fop_put0_lock(unlink_rep_fop);
1363  m0_fop_put0_lock(setattr_rep_fop);
1365  return M0_RC(rc);
1366 }
1367 
1368 static int m0t1fs_fid_rmdir(struct inode *dir, struct dentry *dentry)
1369 {
1371  return M0_ERR(-EOPNOTSUPP);
1372 }
1373 
1374 static int m0t1fs_rmdir(struct inode *dir, struct dentry *dentry)
1375 {
1376  int rc;
1377 
1379  M0_ENTRY();
1380  rc = m0t1fs_unlink(dir, dentry);
1381  if (rc == 0) {
1382  inode_dec_link_count(dentry->d_inode);
1383  drop_nlink(dir);
1384  }
1385  return M0_RC(rc);
1386 }
1387 
1389  struct m0_fop_cob *body, struct kstat *stat)
1390 {
1391  struct m0t1fs_inode *ci = M0T1FS_I(inode);
1392  struct m0t1fs_sb *csb = M0T1FS_SB(inode->i_sb);
1393  int rc;
1394 
1395  if (body != NULL) {
1397  if (m0_pool_version_find(&csb->csb_pools_common,
1398  &body->b_pver) == NULL)
1399  return M0_ERR(-EINVAL);
1401  if (rc != 0)
1402  return rc;
1403  }
1404 
1406  stat->dev = inode->i_sb->s_dev;
1407  stat->ino = inode->i_ino;
1408  stat->mode = inode->i_mode;
1409  stat->nlink = inode->i_nlink;
1410  stat->uid = inode->i_uid;
1411  stat->gid = inode->i_gid;
1412  stat->rdev = inode->i_rdev;
1413  stat->atime = inode->i_atime;
1414  stat->mtime = inode->i_mtime;
1415  stat->ctime = inode->i_ctime;
1416 #ifdef HAVE_INODE_BLKSIZE
1417  stat->blksize = inode->i_blksize;
1418 #else
1419  stat->blksize = 1 << inode->i_blkbits;
1420 #endif
1421  stat->size = i_size_read(inode);
1422  stat->blocks = stat->blksize ? stat->size / stat->blksize : 0;
1423  return 0;
1424 }
1425 
1426 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
1427 M0_INTERNAL int m0t1fs_fid_getattr(const struct path *path, struct kstat *stat,
1428  uint32_t request_mask, uint32_t query_flags)
1429 #else
1430 M0_INTERNAL int m0t1fs_fid_getattr(struct vfsmount *mnt, struct dentry *dentry,
1431  struct kstat *stat)
1432 #endif
1434  struct m0t1fs_sb *csb;
1435  struct inode *inode;
1436  struct m0_fop_cob *body;
1437  int rc;
1438 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
1439  struct dentry *dentry = path->dentry;
1440 #endif
1442  M0_ENTRY();
1443 
1444 
1445  M0_LOG(M0_INFO, "Name: \"%s\"", (char*)dentry->d_name.name);
1446 
1447  inode = dentry->d_inode;
1448  csb = M0T1FS_SB(inode->i_sb);
1449 
1451  if (rc != 0)
1452  return M0_ERR(rc);
1453 
1454  /* Return cached attributes for files in .motr/fid dir */
1455  body = &csb->csb_virt_body;
1458  return M0_RC(rc);
1459 }
1460 
1461 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
1462 M0_INTERNAL int m0t1fs_getattr(const struct path *path, struct kstat *stat,
1463  uint32_t request_mask, uint32_t query_flags)
1464 #else
1465 M0_INTERNAL int m0t1fs_getattr(struct vfsmount *mnt, struct dentry *dentry,
1466  struct kstat *stat)
1467 #endif
1468 {
1469  struct m0_fop_getattr_rep *getattr_rep;
1470  struct m0t1fs_sb *csb;
1471  struct inode *inode;
1472  struct m0_fop_cob *body;
1473  struct m0t1fs_inode *ci;
1474  struct m0t1fs_mdop mo;
1475  int rc = 0;
1476  struct m0_fop *rep_fop = NULL;
1477 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
1478  struct dentry *dentry = path->dentry;
1479 #endif
1481  M0_ENTRY();
1482 
1483  M0_LOG(M0_INFO, "Name: \"%s\"", (char*)dentry->d_name.name);
1484  inode = dentry->d_inode;
1485 
1486  csb = M0T1FS_SB(inode->i_sb);
1487  ci = M0T1FS_I(inode);
1488 
1490  if (rc != 0)
1491  return M0_ERR(rc);
1492  if (m0t1fs_inode_is_root(&ci->ci_inode)) {
1494  goto out;
1495  }
1496  if (csb->csb_oostore) {
1499  goto out;
1500  }
1501 
1502  M0_SET0(&mo);
1503  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
1504  m0_buf_init(&mo.mo_attr.ca_name,
1505  (char*)dentry->d_name.name, dentry->d_name.len);
1506 
1514  if (rc != 0)
1515  goto out;
1516  getattr_rep = m0_fop_data(rep_fop);
1517  body = &getattr_rep->g_body;
1519 out:
1522  return M0_RC(rc);
1523 }
1524 
1525 M0_INTERNAL int m0t1fs_size_update(struct dentry *dentry, uint64_t newsize)
1526 {
1527  struct m0t1fs_sb *csb;
1528  struct inode *inode;
1529  struct m0t1fs_inode *ci;
1530  struct m0t1fs_mdop mo;
1531  int rc = 0;
1532  struct m0_fop *rep_fop = NULL;
1533 
1534  inode = dentry->d_inode;
1535  csb = M0T1FS_SB(inode->i_sb);
1536  ci = M0T1FS_I(inode);
1537 
1539  if (csb->csb_oostore) {
1540  inode->i_size = newsize;
1541  goto out;
1542  }
1543  M0_SET0(&mo);
1544  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
1545  mo.mo_attr.ca_size = newsize;
1546  mo.mo_attr.ca_valid |= M0_COB_SIZE;
1547  m0_buf_init(&mo.mo_attr.ca_name, (char*)dentry->d_name.name,
1548  dentry->d_name.len);
1549 
1551  if (rc != 0)
1552  goto out;
1553  inode->i_size = newsize;
1554 out:
1557  return M0_RC(rc);
1558 }
1559 
1560 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
1561 M0_INTERNAL int m0t1fs_fid_setxattr(const struct xattr_handler *handler,
1562  struct dentry *dentry, struct inode *inode,
1563  const char *name, const void *value,
1564  size_t size, int flags)
1565 #else
1566 M0_INTERNAL int m0t1fs_fid_setxattr(struct dentry *dentry, const char *name,
1567  const void *value, size_t size, int flags)
1568 #endif
1569 {
1571 
1572 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
1573  if (value == NULL)
1575 #endif
1576 
1577  return M0_ERR(-EOPNOTSUPP);
1578 }
1579 
1580 M0_INTERNAL int m0t1fs_fid_setattr(struct dentry *dentry, struct iattr *attr)
1581 {
1583  return M0_ERR(-EOPNOTSUPP);
1584 }
1585 
1586 M0_INTERNAL int m0t1fs_setattr(struct dentry *dentry, struct iattr *attr)
1587 {
1588  struct m0t1fs_sb *csb;
1589  struct inode *inode;
1590  struct m0t1fs_inode *ci;
1591  struct m0t1fs_mdop mo;
1592  int rc;
1593  struct m0_fop *rep_fop = NULL;
1594  struct m0_rm_incoming rm_in;
1595 
1597  M0_ENTRY();
1598 
1599  M0_LOG(M0_INFO, "Name: \"%s\"", (char*)dentry->d_name.name);
1600 
1601  inode = dentry->d_inode;
1602  csb = M0T1FS_SB(inode->i_sb);
1603  ci = M0T1FS_I(inode);
1604 
1605 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
1606  rc = setattr_prepare(dentry, attr);
1607 #else
1608  rc = inode_change_ok(inode, attr);
1609 #endif
1610  if (rc != 0)
1611  return M0_ERR(rc);
1612 
1614  if (rc != 0)
1615  return M0_ERR(rc);
1616 
1617  if (!csb->csb_oostore) {
1618  rc = file_lock_acquire(&rm_in, ci);
1619  if (rc != 0)
1620  goto out;
1621  }
1622  M0_SET0(&mo);
1623 
1624  if (m0_fid_is_set(&ci->ci_pver) && m0_fid_is_valid(&ci->ci_pver)) {
1625  mo.mo_attr.ca_pver = ci->ci_pver;
1626  mo.mo_attr.ca_valid |= M0_COB_PVER;
1627  M0_LOG(M0_DEBUG, "pver" FID_F"for object" FID_F,
1628  FID_P(&ci->ci_pver),
1630  } else {
1631  M0_LOG(M0_ERROR, "invalid inode");
1632  rc = -EINVAL;
1633  goto out;
1634  }
1635  mo.mo_attr.ca_lid = ci->ci_layout_id;
1636  mo.mo_attr.ca_valid |= M0_COB_LID;
1637 
1638  mo.mo_attr.ca_tfid = *m0t1fs_inode_fid(ci);
1639  m0_buf_init(&mo.mo_attr.ca_name, (char*)dentry->d_name.name,
1640  dentry->d_name.len);
1641 
1642  if (attr->ia_valid & ATTR_CTIME) {
1643  mo.mo_attr.ca_ctime = attr->ia_ctime.tv_sec;
1644  mo.mo_attr.ca_valid |= M0_COB_CTIME;
1645  }
1646 
1647  if (attr->ia_valid & ATTR_MTIME) {
1648  mo.mo_attr.ca_mtime = attr->ia_mtime.tv_sec;
1649  mo.mo_attr.ca_valid |= M0_COB_MTIME;
1650  }
1651 
1652  if (attr->ia_valid & ATTR_ATIME) {
1653  mo.mo_attr.ca_atime = attr->ia_atime.tv_sec;
1654  mo.mo_attr.ca_valid |= M0_COB_ATIME;
1655  }
1656 
1657  if (attr->ia_valid & ATTR_SIZE) {
1658  mo.mo_attr.ca_size = attr->ia_size;
1659  mo.mo_attr.ca_valid |= M0_COB_SIZE;
1660  }
1661 
1662  if (attr->ia_valid & ATTR_MODE) {
1663  mo.mo_attr.ca_mode = attr->ia_mode;
1664  mo.mo_attr.ca_valid |= M0_COB_MODE;
1665  }
1666 
1667  if (attr->ia_valid & ATTR_UID) {
1668 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
1669  mo.mo_attr.ca_uid = from_kuid(current_user_ns(), attr->ia_uid);
1670 #else
1671  mo.mo_attr.ca_uid = attr->ia_uid;
1672 #endif
1673  mo.mo_attr.ca_valid |= M0_COB_UID;
1674  }
1675 
1676  if (attr->ia_valid & ATTR_GID) {
1677 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
1678  mo.mo_attr.ca_gid = from_kgid(current_user_ns(), attr->ia_gid);
1679 #else
1680  mo.mo_attr.ca_gid = attr->ia_gid;
1681 #endif
1682  mo.mo_attr.ca_valid |= M0_COB_GID;
1683  }
1684 
1685  mo.mo_attr.ca_nlink = inode->i_nlink;
1686  mo.mo_attr.ca_valid |= M0_COB_NLINK;
1687 
1688  /*
1689  * Layout can be changed explicitly in setattr()
1690  * to a new layout, e.g. to a composite layout in NBA.
1691  * Check for that use case and update layout id for this
1692  * file. When that happens, a special setattr() with
1693  * valid layout id should be called.
1694  */
1695 
1696  if (!csb->csb_oostore) {
1698  if (rc != 0)
1699  goto out;
1700  } else {
1703  if (rc != 0)
1704  goto out;
1705  }
1706  if (attr->ia_valid & ATTR_SIZE && attr->ia_size < inode->i_size) {
1709  if (rc != 0)
1710  goto out;
1711  }
1712 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
1713  setattr_copy(inode, attr);
1714  if (attr->ia_valid & ATTR_SIZE)
1715  i_size_write(inode, attr->ia_size);
1716 #else
1717  rc = inode_setattr(inode, attr);
1718  if (rc != 0)
1719  goto out;
1720 #endif
1721 out:
1722  if (!csb->csb_oostore)
1723  file_lock_release(&rm_in);
1724 
1727  return M0_RC(rc);
1728 }
1729 
1730 static int file_lock_acquire(struct m0_rm_incoming *rm_in,
1731  struct m0t1fs_inode *ci)
1732 {
1733  struct m0t1fs_sb *csb;
1734  int rc;
1735 
1736  csb = M0T1FS_SB(ci->ci_inode.i_sb);
1737  M0_PRE(!csb->csb_oostore);
1738 
1740  m0_file_lock(&ci->ci_fowner, rm_in);
1741  m0_rm_owner_lock(&ci->ci_fowner);
1743  M0_TIME_NEVER);
1744  m0_rm_owner_unlock(&ci->ci_fowner);
1745  rc = rc ? : rm_in->rin_rc;
1746  return rc;
1747 }
1748 
1749 static void file_lock_release(struct m0_rm_incoming *rm_in)
1750 {
1751  M0_PRE(rm_in != NULL);
1752  m0_file_unlock(rm_in);
1753 }
1754 
1755 static int m0t1fs_component_objects_op(struct m0t1fs_inode *ci,
1756  struct m0t1fs_mdop *mop,
1757  int (*func)(struct cob_req *,
1758  const struct m0t1fs_inode *,
1759  const struct m0t1fs_mdop *,
1760  int idx))
1761 {
1762  struct m0t1fs_sb *csb;
1763  struct cob_req cob_req;
1764  int i = 0;
1765  int rc = 0;
1766  const char *op_name;
1767  struct m0_pool_version *pv;
1768  struct m0_pools_common *pc;
1769 
1770  M0_PRE(ci != NULL);
1771  M0_PRE(func != NULL);
1772 
1773  M0_ENTRY();
1774 
1775  op_name = (func == m0t1fs_ios_cob_create) ? "create" :
1776  (func == m0t1fs_ios_cob_delete) ? "delete" :
1777  (func == m0t1fs_ios_cob_truncate) ? "truncate" : "setattr";
1778  csb = M0T1FS_SB(ci->ci_inode.i_sb);
1779  pc = &csb->csb_pools_common;
1780 
1781  M0_LOG(M0_DEBUG, "%s Component object %s for "FID_F,
1782  csb->csb_oostore ? "oostore mode" : "",
1783  op_name, FID_P(m0t1fs_inode_fid(ci)));
1784 
1786 
1788  cob_req.cr_csb = csb;
1789  cob_req.cr_rc = 0;
1791  cob_req.cr_pver = ci->ci_pver;
1792 
1793  if (csb->csb_oostore && func != m0t1fs_ios_cob_truncate) {
1794  M0_LOG(M0_DEBUG,"oostore mode");
1795  mop->mo_cob_type = M0_COB_MD;
1796  /*
1797  * Create, delete and setattr operations on meta data cobs on
1798  * ioservices are performed.
1799  */
1800  for (i = 0; i < pc->pc_md_redundancy && rc == 0; i++)
1801  rc = func(&cob_req, ci, mop, i);
1802  while (--i >= 0)
1804 
1805  if (rc != 0 ||
1806  func == m0t1fs_ios_cob_setattr ||
1807  func == m0t1fs_ios_cob_create ||
1808  /* Data cobs are not createed until first write (CROW). */
1809  ci->ci_inode.i_size <= 0)
1810  goto out;
1811  }
1812 
1813  pv = m0_pool_version_find(pc, &ci->ci_pver);
1814  if (pv == NULL) {
1815  M0_LOG(M0_ERROR, "Failed to get pool version "FID_F"",
1816  FID_P(&ci->ci_pver));
1817  goto out;
1818  }
1819 
1820  mop->mo_cob_type = M0_COB_IO;
1821  for (i = 0; i < pv->pv_attr.pa_P && rc == 0; i++)
1822  rc = func(&cob_req, ci, mop, i);
1823  while (--i >= 0)
1825 out:
1827  M0_LOG(M0_DEBUG, "Cob %s "FID_F" with %d", op_name,
1829 
1830  return M0_RC(rc ?: cob_req.cr_rc);
1831 }
1832 
1833 static int m0t1fs_mds_cob_fop_populate(struct m0t1fs_sb *csb,
1834  const struct m0t1fs_mdop *mo,
1835  struct m0_fop *fop)
1836 {
1837  struct m0_fop_create *create;
1838  struct m0_fop_unlink *unlink;
1839  struct m0_fop_link *link;
1840  struct m0_fop_lookup *lookup;
1841  struct m0_fop_getattr *getattr;
1842  struct m0_fop_statfs *statfs;
1843  struct m0_fop_setattr *setattr;
1844  struct m0_fop_readdir *readdir;
1845  struct m0_fop_setxattr *setxattr;
1846  struct m0_fop_getxattr *getxattr;
1847  struct m0_fop_listxattr *listxattr;
1848  struct m0_fop_delxattr *delxattr;
1849  struct m0_fop_cob *req;
1850  int rc = 0;
1851 
1852  switch (m0_fop_opcode(fop)) {
1854  create = m0_fop_data(fop);
1855  req = &create->c_body;
1856 
1857  req->b_pfid = mo->mo_attr.ca_pfid;
1858  req->b_tfid = mo->mo_attr.ca_tfid;
1859  req->b_pver = mo->mo_attr.ca_pver;
1860  body_mem2wire(req, &mo->mo_attr, mo->mo_attr.ca_valid);
1861  rc = name_mem2wire(&create->c_name, &mo->mo_attr.ca_name);
1862  break;
1864  link = m0_fop_data(fop);
1865  req = &link->l_body;
1866 
1867  req->b_pfid = mo->mo_attr.ca_pfid;
1868  req->b_tfid = mo->mo_attr.ca_tfid;
1869  body_mem2wire(req, &mo->mo_attr, mo->mo_attr.ca_valid);
1870  rc = name_mem2wire(&link->l_name, &mo->mo_attr.ca_name);
1871  break;
1873  unlink = m0_fop_data(fop);
1874  req = &unlink->u_body;
1875 
1876  req->b_pfid = mo->mo_attr.ca_pfid;
1877  req->b_tfid = mo->mo_attr.ca_tfid;
1878  body_mem2wire(req, &mo->mo_attr, mo->mo_attr.ca_valid);
1879  rc = name_mem2wire(&unlink->u_name, &mo->mo_attr.ca_name);
1880  break;
1882  statfs = m0_fop_data(fop);
1883  statfs->f_flags = 0;
1884  break;
1886  lookup = m0_fop_data(fop);
1887  req = &lookup->l_body;
1888 
1889  req->b_pfid = mo->mo_attr.ca_pfid;
1890  rc = name_mem2wire(&lookup->l_name, &mo->mo_attr.ca_name);
1891  break;
1893  getattr = m0_fop_data(fop);
1894  req = &getattr->g_body;
1895 
1896  req->b_tfid = mo->mo_attr.ca_tfid;
1897  break;
1899  setattr = m0_fop_data(fop);
1900  req = &setattr->s_body;
1901 
1902  req->b_tfid = mo->mo_attr.ca_tfid;
1903  body_mem2wire(req, &mo->mo_attr, mo->mo_attr.ca_valid);
1904  break;
1906  readdir = m0_fop_data(fop);
1907  req = &readdir->r_body;
1908 
1909  req->b_tfid = mo->mo_attr.ca_tfid;
1910  rc = name_mem2wire(&readdir->r_pos, &mo->mo_attr.ca_name);
1911  break;
1913  setxattr = m0_fop_data(fop);
1914  req = &setxattr->s_body;
1915 
1916  req->b_tfid = mo->mo_attr.ca_tfid;
1917  rc = name_mem2wire(&setxattr->s_key, &mo->mo_attr.ca_eakey) ?:
1918  name_mem2wire(&setxattr->s_value,
1919  &mo->mo_attr.ca_eaval);
1920  break;
1922  getxattr = m0_fop_data(fop);
1923  req = &getxattr->g_body;
1924 
1925  req->b_tfid = mo->mo_attr.ca_tfid;
1926  rc = name_mem2wire(&getxattr->g_key, &mo->mo_attr.ca_eakey);
1927  break;
1929  listxattr = m0_fop_data(fop);
1930  req = &listxattr->l_body;
1931 
1932  req->b_tfid = mo->mo_attr.ca_tfid;
1933  break;
1935  delxattr = m0_fop_data(fop);
1936  req = &delxattr->d_body;
1937 
1938  req->b_tfid = mo->mo_attr.ca_tfid;
1939  rc = name_mem2wire(&delxattr->d_key, &mo->mo_attr.ca_eakey);
1940  break;
1941  default:
1942  rc = M0_ERR(-ENOSYS);
1943  break;
1944  }
1945 
1946  return M0_RC(rc);
1947 }
1948 
1949 static int m0t1fs_mds_cob_op(struct m0t1fs_sb *csb,
1950  const struct m0t1fs_mdop *mo,
1951  struct m0_fop_type *ftype,
1952  struct m0_fop **rep_fop)
1953 {
1954  int rc;
1955  struct m0_fop *fop;
1956  struct m0_rpc_session *session;
1957  struct m0_rpc_item *item = NULL;
1958  union {
1959  struct m0_fop_create_rep *create_rep;
1960  struct m0_fop_unlink_rep *unlink_rep;
1961  struct m0_fop_rename_rep *rename_rep;
1962  struct m0_fop_link_rep *link_rep;
1963  struct m0_fop_setattr_rep *setattr_rep;
1964  struct m0_fop_getattr_rep *getattr_rep;
1965  struct m0_fop_statfs_rep *statfs_rep;
1966  struct m0_fop_lookup_rep *lookup_rep;
1967  struct m0_fop_open_rep *open_rep;
1968  struct m0_fop_close_rep *close_rep;
1969  struct m0_fop_readdir_rep *readdir_rep;
1970  struct m0_fop_setxattr_rep *setxattr_rep;
1971  struct m0_fop_getxattr_rep *getxattr_rep;
1972  struct m0_fop_listxattr_rep *listxattr_rep;
1973  struct m0_fop_delxattr_rep *delxattr_rep;
1974  } u;
1975  void *reply_data;
1976  struct m0_reqh_service_ctx *ctx;
1977  struct m0_be_tx_remid *remid = NULL;
1978 
1979  M0_PRE(csb != NULL);
1980  M0_PRE(mo != NULL);
1981  M0_PRE(rep_fop != NULL);
1982  M0_PRE(ftype != NULL);
1983 
1984  M0_ENTRY();
1985 
1986  *rep_fop = NULL;
1988  mo->mo_attr.ca_name.b_addr,
1989  mo->mo_attr.ca_name.b_nob,
1990  mo->mo_use_hint,
1991  mo->mo_hash_hint);
1993  if (rc != 0)
1994  return M0_ERR(rc);
1995 
1996  fop = m0_fop_alloc_at(session, ftype);
1997  if (fop == NULL) {
1998  rc = M0_ERR(-ENOMEM);
1999  M0_LOG(M0_ERROR, "m0_fop_alloc() failed with %d", rc);
2000  goto out;
2001  }
2002 
2004 
2006  if (rc != 0) {
2007  M0_LOG(M0_ERROR,
2008  "%p[%u] m0t1fs_mds_cob_fop_populate() failed with %d",
2009  item, m0_fop_opcode(fop), rc);
2010  goto out;
2011  }
2012 
2013  M0_LOG(M0_DEBUG, "%p[%u] Send md operation to session %p (sid=%lu)",
2015  (unsigned long)session->s_session_id);
2016  rc = m0_rpc_post_sync(fop, session, NULL, 0 /* deadline */);
2017  if (rc != 0) {
2018  M0_LOG(M0_ERROR, "%p[%u] m0_rpc_post_sync failed with %d",
2019  item, m0_fop_opcode(fop), rc);
2020  goto out;
2021  }
2022 
2024  m0_fop_get(*rep_fop);
2026 
2032  switch (m0_fop_opcode(fop)) {
2034  u.create_rep = reply_data;
2035  rc = u.create_rep->c_body.b_rc;
2036  remid = &u.create_rep->c_mod_rep.fmr_remid;
2037  break;
2039  u.statfs_rep = reply_data;
2040  rc = u.statfs_rep->f_rc;
2041  break;
2043  u.lookup_rep = reply_data;
2044  rc = u.lookup_rep->l_body.b_rc;
2045  break;
2047  u.link_rep = reply_data;
2048  rc = u.link_rep->l_body.b_rc;
2049  remid = &u.link_rep->l_mod_rep.fmr_remid;
2050  break;
2052  u.unlink_rep = reply_data;
2053  rc = u.unlink_rep->u_body.b_rc;
2054  remid = &u.unlink_rep->u_mod_rep.fmr_remid;
2055  break;
2057  u.rename_rep = reply_data;
2058  rc = u.rename_rep->r_body.b_rc;
2059  remid = &u.rename_rep->r_mod_rep.fmr_remid;
2060  break;
2062  u.setattr_rep = reply_data;
2063  rc = u.setattr_rep->s_body.b_rc;
2064  remid = &u.setattr_rep->s_mod_rep.fmr_remid;
2065  break;
2067  u.getattr_rep = reply_data;
2068  rc = u.getattr_rep->g_body.b_rc;
2069  break;
2071  u.open_rep = reply_data;
2072  rc = u.open_rep->o_body.b_rc;
2073  remid = &u.open_rep->o_mod_rep.fmr_remid;
2074  break;
2076  u.close_rep = reply_data;
2077  rc = u.close_rep->c_body.b_rc;
2078  break;
2080  u.readdir_rep = reply_data;
2081  rc = u.readdir_rep->r_body.b_rc;
2082  break;
2084  u.setxattr_rep = reply_data;
2085  rc = u.setxattr_rep->s_body.b_rc;
2086  remid = &u.setxattr_rep->s_mod_rep.fmr_remid;
2087  break;
2089  u.getxattr_rep = reply_data;
2090  rc = u.getxattr_rep->g_body.b_rc;
2091  break;
2093  u.listxattr_rep = reply_data;
2094  rc = u.listxattr_rep->l_body.b_rc;
2095  break;
2097  u.delxattr_rep = reply_data;
2098  rc = u.delxattr_rep->d_body.b_rc;
2099  remid = &u.delxattr_rep->d_mod_rep.fmr_remid;
2100  break;
2101  default:
2102  M0_LOG(M0_ERROR, "%p[%u] Unexpected fop opcode",
2103  item, m0_fop_opcode(fop));
2104  rc = M0_ERR(-ENOSYS);
2105  goto out;
2106  }
2107 
2108  /* update pending transaction number */
2110  if (remid != NULL)
2112 
2113 out:
2114  M0_LOG(M0_DEBUG, "%p[%u], rc %d", item, m0_fop_opcode(fop), rc);
2116  return M0_RC(rc);
2117 }
2118 
2119 int m0t1fs_mds_statfs(struct m0t1fs_sb *csb, struct m0_fop **rep_fop)
2120 {
2121  struct m0t1fs_mdop mo;
2122  M0_SET0(&mo);
2124 }
2125 
2126 int m0t1fs_mds_cob_create(struct m0t1fs_sb *csb,
2127  const struct m0t1fs_mdop *mo,
2128  struct m0_fop **rep_fop)
2129 {
2131 }
2132 
2133 int m0t1fs_mds_cob_unlink(struct m0t1fs_sb *csb,
2134  const struct m0t1fs_mdop *mo,
2135  struct m0_fop **rep_fop)
2136 {
2138 }
2139 
2140 int m0t1fs_mds_cob_link(struct m0t1fs_sb *csb,
2141  const struct m0t1fs_mdop *mo,
2142  struct m0_fop **rep_fop)
2143 {
2145 }
2146 
2147 int m0t1fs_mds_cob_lookup(struct m0t1fs_sb *csb,
2148  const struct m0t1fs_mdop *mo,
2149  struct m0_fop **rep_fop)
2150 {
2152 }
2153 
2154 int m0t1fs_mds_cob_getattr(struct m0t1fs_sb *csb,
2155  const struct m0t1fs_mdop *mo,
2156  struct m0_fop **rep_fop)
2157 {
2159 }
2160 
2161 int m0t1fs_mds_cob_setattr(struct m0t1fs_sb *csb,
2162  const struct m0t1fs_mdop *mo,
2163  struct m0_fop **rep_fop)
2164 {
2166 }
2167 
2168 int m0t1fs_mds_cob_readdir(struct m0t1fs_sb *csb,
2169  const struct m0t1fs_mdop *mo,
2170  struct m0_fop **rep_fop)
2171 {
2173 }
2174 
2175 int m0t1fs_mds_cob_setxattr(struct m0t1fs_sb *csb,
2176  const struct m0t1fs_mdop *mo,
2177  struct m0_fop **rep_fop)
2178 {
2180 }
2181 
2182 int m0t1fs_mds_cob_getxattr(struct m0t1fs_sb *csb,
2183  const struct m0t1fs_mdop *mo,
2184  struct m0_fop **rep_fop)
2185 {
2187 }
2188 
2189 int m0t1fs_mds_cob_listxattr(struct m0t1fs_sb *csb,
2190  const struct m0t1fs_mdop *mo,
2191  struct m0_fop **rep_fop)
2192 {
2194 }
2195 
2196 int m0t1fs_mds_cob_delxattr(struct m0t1fs_sb *csb,
2197  const struct m0t1fs_mdop *mo,
2198  struct m0_fop **rep_fop)
2199 {
2201 }
2202 
2203 static int m0t1fs_ios_cob_fop_populate(struct m0t1fs_sb *csb,
2204  const struct m0t1fs_mdop *mop,
2205  struct m0_fop *fop,
2206  const struct m0_fid *cob_fid,
2207  const struct m0_fid *gob_fid,
2208  uint32_t cob_idx)
2209 {
2210  struct m0_fop_cob_common *common;
2211  struct m0_fop_cob_truncate *ct;
2212 
2213  M0_PRE(fop != NULL);
2214  M0_PRE(fop->f_type != NULL);
2215  M0_PRE(cob_fid != NULL);
2216  M0_PRE(gob_fid != NULL);
2217 
2218  M0_ENTRY();
2219 
2220  common = m0_cobfop_common_get(fop);
2221  M0_ASSERT(common != NULL);
2222 
2223  body_mem2wire(&common->c_body, &mop->mo_attr, mop->mo_attr.ca_valid);
2224 
2225  common->c_gobfid = *gob_fid;
2226  common->c_cobfid = *cob_fid;
2227  common->c_pver = mop->mo_attr.ca_pver;
2228  common->c_cob_idx = cob_idx;
2229  common->c_cob_type = mop->mo_cob_type;
2230 
2232  common->c_flags |= M0_IO_FLAG_CROW;
2233 
2234  if (m0_is_cob_truncate_fop(fop)) {
2235  ct = m0_fop_data(fop);
2236  ct->ct_size = mop->mo_attr.ca_size;
2237  }
2238 
2239  return M0_RC(0);
2240 }
2241 
2242 static void cfop_release(struct m0_ref *ref)
2243 {
2244  struct m0_fop *fop;
2245  struct cob_fop *cfop;
2246  struct cob_req *creq;
2247 
2248  M0_ENTRY();
2249  M0_PRE(ref != NULL);
2250 
2251  fop = container_of(ref, struct m0_fop, f_ref);
2252  cfop = container_of(fop, struct cob_fop, c_fop);
2253  creq = cfop->c_req;
2254  M0_LOG(M0_DEBUG, "%p[%u] ri_error %d, cob_req_fop %p, cr_rc %d, "
2256  fop->f_item.ri_error, cfop, creq->cr_rc,
2257  FID_P(&creq->cr_fid));
2258  m0_fop_fini(fop);
2259  m0_free(cfop);
2260 
2261  M0_LEAVE();
2262 }
2263 
2264 static int m0t1fs_ios_cob_op(struct cob_req *cr,
2265  const struct m0t1fs_inode *ci,
2266  const struct m0t1fs_mdop *mop,
2267  int idx,
2268  struct m0_fop_type *ftype)
2269 {
2270  int rc;
2271  struct m0t1fs_sb *csb;
2272  struct m0_fid cob_fid;
2273  const struct m0_fid *gob_fid;
2274  uint32_t cob_idx;
2275  struct m0_fop *fop = NULL;
2276  struct cob_fop *cfop;
2277  struct m0_rpc_session *session;
2278  struct m0_pool_version *pver;
2279 
2280  M0_PRE(ci != NULL);
2281  M0_PRE(ftype != NULL);
2282 
2283  M0_ENTRY();
2284 
2285  csb = M0T1FS_SB(ci->ci_inode.i_sb);
2287 
2288  pver = m0_pool_version_find(&csb->csb_pools_common, &ci->ci_pver);
2289  if (pver == NULL) {
2290  M0_ASSERT(ci->ci_layout_instance == NULL);
2291  return M0_ERR_INFO(-ENOENT, "Pool version "FID_F" associated"
2292  " with gob "FID_F" is unavailable."
2293  " Has configuration got updated?",
2294  FID_P(&ci->ci_pver), FID_P(gob_fid));
2295  }
2296  if (mop->mo_cob_type == M0_COB_MD) {
2298  &csb->csb_reqh, gob_fid, idx);
2300  cob_idx = idx;
2301  } else {
2302  m0_poolmach_gob2cob(&pver->pv_mach, gob_fid, idx, &cob_fid);
2303  cob_idx = m0_fid_cob_device_id(&cob_fid);
2304  M0_ASSERT(cob_idx != ~0);
2306  }
2307  M0_ASSERT(session != NULL);
2308 
2309  M0_ALLOC_PTR(cfop);
2310  if (cfop == NULL) {
2311  rc = M0_ERR(-ENOMEM);
2312  M0_LOG(M0_ERROR, "cob_fop malloc failed");
2313  goto out;
2314  }
2315 
2316  cfop->c_req = cr;
2317  fop = &cfop->c_fop;
2318 
2319  m0_fop_init(fop, ftype, NULL, cfop_release);
2321  if (rc != 0) {
2322  m0_fop_fini(fop);
2323  m0_free(cfop);
2324  M0_LOG(M0_ERROR, "cob_fop data malloc failed");
2325  goto out;
2326  }
2328 
2331 
2333  cob_idx);
2334  if (rc != 0)
2335  goto fop_put;
2336 
2337  M0_LOG(M0_DEBUG, "%p[%u] Send %s %d:"FID_F" to session %p (sid=%lu)",
2338  &fop->f_item, m0_fop_opcode(fop), m0_fop_name(fop), (int)cob_idx,
2339  FID_P(&cob_fid), session, (unsigned long)session->s_session_id);
2340 
2343  fop->f_item.ri_deadline = cr->cr_deadline; /* pack fops */
2344  fop->f_item.ri_nr_sent_max = M0T1FS_RPC_MAX_RETRIES;
2345  fop->f_item.ri_resend_interval = M0T1FS_RPC_RESEND_INTERVAL;
2346  rc = m0_rpc_post(&fop->f_item);
2347 fop_put:
2349 out:
2350  return M0_RC(rc);
2351 }
2352 
2353 static int m0t1fs_ios_cob_create(struct cob_req *cr,
2354  const struct m0t1fs_inode *inode,
2355  const struct m0t1fs_mdop *mop,
2356  int idx)
2357 {
2358  return m0t1fs_ios_cob_op(cr, inode, mop, idx, &m0_fop_cob_create_fopt);
2359 }
2360 
2361 static int m0t1fs_ios_cob_delete(struct cob_req *cr,
2362  const struct m0t1fs_inode *inode,
2363  const struct m0t1fs_mdop *mop,
2364  int idx)
2365 {
2366  return m0t1fs_ios_cob_op(cr, inode, mop, idx, &m0_fop_cob_delete_fopt);
2367 }
2368 
2369 static int m0t1fs_ios_cob_truncate(struct cob_req *cr,
2370  const struct m0t1fs_inode *inode,
2371  const struct m0t1fs_mdop *mop,
2372  int idx)
2373 {
2374  return m0t1fs_ios_cob_op(cr, inode, mop, idx,
2376 }
2377 
2378 static int m0t1fs_ios_cob_setattr(struct cob_req *cr,
2379  const struct m0t1fs_inode *inode,
2380  const struct m0t1fs_mdop *mop,
2381  int idx)
2382 {
2383  return m0t1fs_ios_cob_op(cr, inode, mop, idx, &m0_fop_cob_setattr_fopt);
2384 }
2385 
2386 M0_INTERNAL int m0t1fs_cob_getattr(struct inode *inode)
2387 {
2388  struct m0t1fs_sb *csb;
2389  struct m0t1fs_inode *ci;
2390  const struct m0_fid *gob_fid;
2391  struct m0_fop *fop = NULL;
2392  struct m0_fop_cob *body;
2393  struct m0_fid cob_fid;
2394  int rc = 0;
2395  struct m0_cob_attr attr;
2396  struct m0_rpc_session *session = NULL;
2397  struct m0t1fs_mdop mo;
2398  uint32_t i;
2399  struct m0_fop_cob_getattr_reply *getattr_rep;
2400 
2401  M0_ENTRY();
2402 
2403  csb = M0T1FS_SB(inode->i_sb);
2404  ci = M0T1FS_I(inode);
2405 
2407 
2408  for (i = 0; i < csb->csb_pools_common.pc_md_redundancy; i++) {
2410  &csb->csb_reqh, gob_fid, i);
2412  if (rc != 0) {
2413  if (rc == -ECANCELED)
2414  continue;
2415  return M0_ERR(rc);
2416  }
2418 
2419  M0_LOG(M0_DEBUG, "Getattr for "FID_F "~" FID_F,
2420  FID_P(gob_fid), FID_P(&cob_fid));
2421 
2423  if (fop == NULL) {
2424  rc = -ENOMEM;
2425  M0_LOG(M0_ERROR, "m0_fop_alloc() failed with %d", rc);
2426  return M0_RC(rc);
2427  }
2428 
2429  M0_SET0(&mo);
2430  mo.mo_attr.ca_pfid = *gob_fid;
2431  mo.mo_attr.ca_tfid = *gob_fid;
2432  mo.mo_cob_type = M0_COB_MD;
2433  mo.mo_attr.ca_pver = ci->ci_pver;
2435 
2436  M0_LOG(M0_DEBUG, "%p[%u] Send cob operation %s to session %p"
2437  "(sid=%lu)", &fop->f_item, m0_fop_opcode(fop),
2439  (unsigned long)session->s_session_id);
2440 
2441  fop->f_item.ri_nr_sent_max = M0T1FS_RPC_MAX_RETRIES;
2442  fop->f_item.ri_resend_interval = M0T1FS_RPC_RESEND_INTERVAL;
2443  rc = m0_rpc_post_sync(fop, session, NULL, 0 /* deadline */);
2444  if (rc != 0) {
2445  M0_LOG(M0_ERROR, "%p[%u] getattr returned: %d", &fop->f_item,
2446  m0_fop_opcode(fop), rc);
2448  if (rc == -ECANCELED)
2449  continue;
2450  return M0_RC(rc);
2451  }
2452  getattr_rep = m0_fop_data(m0_rpc_item_to_fop(
2453  fop->f_item.ri_reply));
2454  rc = getattr_rep->cgr_rc;
2455  M0_LOG(M0_DEBUG, "%p[%u] getattr returned: %d", &fop->f_item,
2456  m0_fop_opcode(fop), rc);
2457 
2458  if (rc == 0) {
2459  body = &getattr_rep->cgr_body;
2460  body_wire2mem(&attr, body);
2462  /* Update inode fields with data from @getattr_rep. */
2464  if (m0_pool_version_find(&csb->csb_pools_common,
2465  &body->b_pver) == NULL)
2466  return M0_ERR(-EINVAL);
2469  break;
2470  }
2472  }
2473 
2474  return M0_RC(rc);
2475 }
2476 
2477 M0_INTERNAL int m0t1fs_cob_setattr(struct inode *inode, struct m0t1fs_mdop *mo)
2478 {
2479  struct m0t1fs_inode *ci = M0T1FS_I(inode);
2480  struct m0t1fs_sb *csb = M0T1FS_SB(inode->i_sb);
2481  int rc;
2482  M0_ENTRY();
2483 
2485  if (rc != 0)
2486  return M0_ERR(rc);
2487 
2488  /* Updating size to ios. */
2490 
2492  return M0_RC(rc);
2493 }
2494 
2495 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
2496 const struct xattr_handler m0t1fs_xattr_lid = {
2497  .name = "lid",
2498  .flags = 0,
2499  .get = m0t1fs_getxattr,
2500  .set = m0t1fs_setxattr,
2501 };
2502 
2503 const struct xattr_handler m0t1fs_xattr_pver = {
2504  .name = "pver",
2505  .flags = 0,
2506  .get = m0t1fs_getxattr,
2507 };
2508 
2509 const struct xattr_handler m0t1fs_xattr_writesize = {
2510  .name = "writesize",
2511  .flags = 0,
2512  .get = m0t1fs_getxattr,
2513  .set = m0t1fs_setxattr,
2514 };
2515 static const struct xattr_handler m0t1fs_xattr_fid_lid = {
2516  .name = "fid_lid",
2517  .flags = 0,
2518  .get = m0t1fs_fid_getxattr,
2519  .set = m0t1fs_fid_setxattr,
2520 };
2521 
2522 static const struct xattr_handler m0t1fs_xattr_fid_writesize = {
2523  .name = "fid_writesize",
2524  .flags = 0,
2525  .get = m0t1fs_fid_getxattr,
2526  .set = m0t1fs_fid_setxattr,
2527 };
2528 
2529 const struct xattr_handler *m0t1fs_xattr_handlers[] = {
2535  NULL
2536 };
2537 #endif
2538 
2539 const struct file_operations m0t1fs_dir_file_operations = {
2540  .read = generic_read_dir, /* provided by linux kernel */
2541  .open = m0t1fs_opendir,
2542  .release = m0t1fs_releasedir,
2543 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
2544  .iterate = m0t1fs_readdir,
2545 #else
2546  .readdir = m0t1fs_readdir,
2547 #endif
2548 
2549 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
2550  .fsync = generic_file_fsync, /* provided by linux kernel */
2551 #else
2552  .fsync = simple_fsync, /* provided by linux kernel */
2553 #endif
2554  .llseek = generic_file_llseek, /* provided by linux kernel */
2555 };
2556 
2557 const struct file_operations m0t1fs_fid_dir_file_operations = {
2558  .read = generic_read_dir, /* provided by linux kernel */
2559  .open = m0t1fs_fid_opendir,
2560  .release = m0t1fs_fid_releasedir,
2561 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
2562  .iterate = m0t1fs_fid_readdir,
2563 #else
2564  .readdir = m0t1fs_fid_readdir,
2565 #endif
2566 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
2567  .fsync = generic_file_fsync, /* provided by linux kernel */
2568 #else
2569  .fsync = simple_fsync, /* provided by linux kernel */
2570 #endif
2571  .llseek = generic_file_llseek, /* provided by linux kernel */
2572 };
2573 
2574 const struct inode_operations m0t1fs_dir_inode_operations = {
2575  .create = m0t1fs_create,
2576  .lookup = m0t1fs_lookup,
2577  .unlink = m0t1fs_unlink,
2578  .link = m0t1fs_link,
2579  .mkdir = m0t1fs_mkdir,
2580  .rmdir = m0t1fs_rmdir,
2581  .setattr = m0t1fs_setattr,
2582  .getattr = m0t1fs_getattr,
2583 
2584 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0)
2585  .setxattr = m0t1fs_setxattr,
2586  .getxattr = m0t1fs_getxattr,
2587  .removexattr = m0t1fs_removexattr,
2588 #endif
2589  .listxattr = m0t1fs_listxattr,
2590 };
2591 
2592 const struct inode_operations m0t1fs_fid_dir_inode_operations = {
2593  .create = m0t1fs_fid_create,
2594  .lookup = m0t1fs_fid_lookup,
2595  .unlink = m0t1fs_fid_unlink,
2596  .link = m0t1fs_fid_link,
2597  .mkdir = m0t1fs_fid_mkdir,
2598  .rmdir = m0t1fs_fid_rmdir,
2599  .setattr = m0t1fs_fid_setattr,
2600  .getattr = m0t1fs_fid_getattr,
2601 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0)
2602  .setxattr = m0t1fs_fid_setxattr,
2603  .getxattr = m0t1fs_fid_getxattr,
2604  .removexattr = m0t1fs_fid_removexattr,
2605 #endif
2606  .listxattr = m0t1fs_fid_listxattr,
2607 };
2608 
2609 #undef M0_TRACE_SUBSYSTEM
m0_fop_put0_lock(rep_fop)
ssize_t m0t1fs_listxattr(struct dentry *dentry, char *buffer, size_t size)
Definition: dir.c:538
M0_INTERNAL struct inode * m0t1fs_iget(struct super_block *sb, const struct m0_fid *fid, struct m0_fop_cob *body)
Definition: inode.c:489
static int m0t1fs_releasedir(struct inode *inode, struct file *file)
Definition: dir.c:982
uint32_t b_nlink
Definition: md_fops.h:81
const struct xattr_handler m0t1fs_xattr_lid
Definition: dir.c:2496
M0_INTERNAL int m0_rpc_post(struct m0_rpc_item *item)
Definition: rpc.c:63
struct m0_fop_type m0_fop_setxattr_fopt
Definition: md_fops.c:60
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:440
static struct m0_fid gob_fid
Definition: net.c:115
uint32_t b_uid
Definition: md_fops.h:82
uint32_t rit_opcode
Definition: item.h:474
uint32_t m0_fop_opcode(const struct m0_fop *fop)
Definition: fop.c:226
uint64_t c_flags
Definition: io_fops.h:477
char d_name[0]
Definition: cob.h:601
m0_time_t ri_resend_interval
Definition: item.h:144
#define M0_PRE(cond)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
M0_INTERNAL void m0_fid_gob_make(struct m0_fid *gob_fid, uint32_t container, uint64_t key)
Definition: fid_convert.c:46
M0_INTERNAL int m0t1fs_inode_layout_init(struct m0t1fs_inode *ci)
Definition: inode.c:570
int m0t1fs_removexattr(struct dentry *dentry, const char *name)
Definition: dir.c:550
int m0t1fs_mds_cob_lookup(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2147
M0_INTERNAL struct m0_fop_cob_common * m0_cobfop_common_get(struct m0_fop *fop)
Definition: io_fops.c:990
int const char * name
Definition: dir.c:325
int const char const void size_t int flags
Definition: dir.c:328
M0_INTERNAL int struct dentry struct kstat * stat
Definition: dir.c:1433
M0_INTERNAL uint64_t m0_fid_hash(const struct m0_fid *fid)
Definition: fid.c:295
uint32_t b_valid
Definition: md_fops.h:76
#define NULL
Definition: misc.h:38
struct m0_dirent * dirent_next(struct m0_dirent *ent)
Definition: dir.c:937
struct m0_fid b_tfid
Definition: md_fops.h:92
static int name_mem2wire(struct m0_fop_str *tgt, const struct m0_buf *name)
Definition: dir.c:147
const m0_time_t M0_TIME_NEVER
Definition: time.c:108
void * err_ptr
Definition: dir.c:813
M0_INTERNAL struct m0_pool_version * m0_pool_version_find(struct m0_pools_common *pc, const struct m0_fid *id)
Definition: pool.c:586
static FILE * f
Definition: adieu.c:79
static struct io_request req
Definition: file.c:100
struct m0_file file
Definition: di.c:36
struct m0_fop_cob l_body
Definition: md_fops.h:115
union @126 u
M0_INTERNAL void m0_fop_init(struct m0_fop *fop, struct m0_fop_type *fopt, void *data, void(*fop_release)(struct m0_ref *))
Definition: fop.c:79
struct m0_pool_version * pv
Definition: dir.c:629
uint64_t m0_time_t
Definition: time.h:37
static int m0t1fs_rmdir(struct inode *dir, struct dentry *dentry)
Definition: dir.c:1374
M0_LEAVE()
static void file_lock_release(struct m0_rm_incoming *rm_in)
Definition: dir.c:1749
Definition: cob.h:598
static int m0t1fs_link(struct dentry *old, struct inode *dir, struct dentry *new)
Definition: dir.c:1190
struct m0_fop_type m0_fop_statfs_fopt
Definition: md_fops.c:64
static void create(void)
Definition: service_ut.c:546
M0_INTERNAL const struct m0_fid * m0t1fs_inode_fid(const struct m0t1fs_inode *ci)
Definition: inode.c:61
M0_INTERNAL uint32_t m0_bitstring_len_get(const struct m0_bitstring *c)
Definition: bitstring.c:38
int m0t1fs_mds_cob_getattr(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2154
M0_INTERNAL void m0_buf_init(struct m0_buf *buf, void *data, uint32_t nob)
Definition: buf.c:37
struct m0_fop_type m0_fop_getattr_fopt
Definition: md_fops.c:59
const struct address_space_operations m0t1fs_aops
Definition: file.c:6887
static int m0t1fs_mds_cob_fop_populate(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop *fop)
Definition: dir.c:1833
M0_INTERNAL struct m0_rpc_session * m0t1fs_filename_to_mds_session(const struct m0t1fs_sb *csb, const unsigned char *filename, unsigned int nlen, bool use_hint, uint32_t hash_hint)
Definition: super.c:130
struct m0_fop_cob d_body
Definition: md_fops.h:231
int const char const void * value
Definition: dir.c:325
const struct m0_fid_type m0_file_fid_type
Definition: file.c:569
M0_INTERNAL bool m0_is_cob_truncate_fop(const struct m0_fop *fop)
Definition: io_fops.c:964
static void cfop_release(struct m0_ref *ref)
Definition: dir.c:2242
int32_t ri_error
Definition: item.h:161
void * m0_fop_data(const struct m0_fop *fop)
Definition: fop.c:220
uint32_t c_cob_type
Definition: io_fops.h:474
static int m0t1fs_ios_cob_create(struct cob_req *cr, const struct m0t1fs_inode *inode, const struct m0t1fs_mdop *mop, int idx)
Definition: dir.c:2353
M0_INTERNAL void m0_file_lock(struct m0_rm_owner *owner, struct m0_rm_incoming *req)
Definition: file.c:522
struct m0_fop_type m0_fop_create_fopt
Definition: md_fops.c:52
mark_inode_dirty(dir)
static const struct xattr_handler m0t1fs_xattr_fid_writesize
Definition: dir.c:2522
#define M0_BITS(...)
Definition: misc.h:236
struct m0_fid c_cobfid
Definition: io_fops.h:465
ino_t ino
Definition: dir.c:1032
struct m0t1fs_sb * cr_csb
Definition: dir.c:61
struct cob_req * c_req
Definition: dir.c:69
int m0t1fs_mds_cob_unlink(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2133
static int void * buf
Definition: dir.c:1019
uint32_t b_rdev
Definition: md_fops.h:86
uint64_t b_size
Definition: md_fops.h:78
#define container_of(ptr, type, member)
Definition: misc.h:33
struct m0_rm_credit rin_want
Definition: rm.h:1450
static struct m0_rpc_session session
Definition: formation2.c:38
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
static int m0t1fs_fid_link(struct dentry *old, struct inode *dir, struct dentry *new)
Definition: dir.c:1183
M0_ADDB2_ADD(M0_AVI_FS_CREATE, new_fid.f_container, new_fid.f_key, mode, rc)
struct m0_fop_cob r_body
Definition: md_fops.h:253
int m0t1fs_mds_cob_getxattr(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2182
struct m0_fop_type m0_fop_getxattr_fopt
Definition: md_fops.c:61
struct m0t1fs_sb * csb
Definition: dir.c:330
static int m0t1fs_ios_cob_op(struct cob_req *cr, const struct m0t1fs_inode *ci, const struct m0t1fs_mdop *mop, int idx, struct m0_fop_type *ftype)
Definition: dir.c:2264
M0_INTERNAL bool m0_fid_is_set(const struct m0_fid *fid)
Definition: fid.c:106
static struct m0_rpc_item * item
Definition: item.c:56
struct m0_fop_getxattr_rep * rep
Definition: dir.c:455
ci ci_fid
Definition: dir.c:672
static int struct dentry int struct nameidata * nd
Definition: dir.c:593
int m0t1fs_mds_cob_setxattr(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2175
int over
Definition: dir.c:1035
Definition: sock.c:887
static int m0t1fs_fid_releasedir(struct inode *inode, struct file *file)
Definition: dir.c:993
static struct m0_pools_common pc
Definition: iter_ut.c:59
struct inode * inode
Definition: dir.c:624
Definition: dir.c:58
M0_INTERNAL void m0t1fs_inode_bob_init(struct m0t1fs_inode *bob)
struct m0_fop_cob * body
Definition: dir.c:1436
static void body_wire2mem(struct m0_cob_attr *attr, const struct m0_fop_cob *body)
Definition: dir.c:191
M0_INTERNAL int m0_sm_timedwait(struct m0_sm *mach, uint64_t states, m0_time_t deadline)
Definition: sm.c:387
int const char const void size_t size
Definition: dir.c:325
struct m0_fop_str r_pos
Definition: md_fops.h:255
return M0_RC(rc)
M0_LOG(M0_DEBUG, "Creating \s\in pdir %lu "FID_F,(char *) dentry->d_name.name, dir->i_ino, FID_P(m0t1fs_inode_fid(M0T1FS_I(dir))))
struct m0_fop_type m0_fop_cob_getattr_fopt
Definition: io_fops.c:80
struct m0_fop_cob g_body
Definition: md_fops.h:198
Definition: buf.h:37
M0_INTERNAL bool m0t1fs_inode_bob_check(struct m0t1fs_inode *bob)
static int m0t1fs_fid_opendir(struct inode *inode, struct file *file)
Definition: dir.c:976
int i
Definition: dir.c:1033
struct m0_sm rin_sm
Definition: rm.h:1436
struct m0_fop_type * f_type
Definition: fop.h:81
M0_INTERNAL bool m0_is_cob_setattr_fop(const struct m0_fop *fop)
Definition: io_fops.c:978
struct m0_fid new_fid
Definition: dir.c:625
uint32_t b_ctime
Definition: md_fops.h:89
static int m0t1fs_inode_update_stat(struct inode *inode, struct m0_fop_cob *body, struct kstat *stat)
Definition: dir.c:1388
static int64_t max64(int64_t a, int64_t b)
Definition: arith.h:51
M0_INTERNAL void m0t1fs_fs_unlock(struct m0t1fs_sb *csb)
Definition: super.c:112
M0_INTERNAL void m0_fid_set(struct m0_fid *fid, uint64_t container, uint64_t key)
Definition: fid.c:116
#define M0_ERR_INFO(rc, fmt,...)
Definition: trace.h:215
static int m0t1fs_ios_cob_setattr(struct cob_req *cr, const struct m0t1fs_inode *inode, const struct m0t1fs_mdop *mop, int idx)
Definition: dir.c:2378
struct m0_fop_cob cgr_body
Definition: io_fops.h:544
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL const char * m0_fop_name(const struct m0_fop *fop)
Definition: fop.c:55
static int m0t1fs_component_objects_op(struct m0t1fs_inode *ci, struct m0t1fs_mdop *mop, int(*func)(struct cob_req *, const struct m0t1fs_inode *, const struct m0t1fs_mdop *, int idx))
Definition: dir.c:1755
static int m0t1fs_unlink(struct inode *dir, struct dentry *dentry)
Definition: dir.c:1253
uint32_t d_namelen
Definition: cob.h:599
Definition: trace.h:482
int m0t1fs_mds_cob_link(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2140
uint32_t pc_md_redundancy
Definition: pool.h:210
struct m0_fid cr_fid
Definition: dir.c:63
M0_INTERNAL int m0_pool_version_get(struct m0_pools_common *pc, const struct m0_fid *pool, struct m0_pool_version **pv)
Definition: pool.c:662
Definition: refs.h:34
M0_INTERNAL int m0t1fs_fid_getattr(const struct path *path, struct kstat *stat, uint32_t request_mask, uint32_t query_flags) M0_INTERNAL int m0t1fs_fid_getattr(struct vfsmount *mnt
struct m0_fop c_fop
Definition: dir.c:68
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:949
M0_INTERNAL void m0_bitstring_copy(struct m0_bitstring *dst, const char *src, size_t count)
Definition: bitstring.c:63
static int void filldir_t filldir
Definition: dir.c:1022
struct m0_fid pv_id
Definition: pool.h:113
int rc
Definition: dir.c:333
uint8_t * s_buf
Definition: string.h:72
#define m0_free0(pptr)
Definition: memory.h:77
struct m0_fop_type m0_fop_cob_setattr_fopt
Definition: io_fops.c:83
#define M0_ASSERT(cond)
M0_INTERNAL void m0t1fs_fs_conf_unlock(struct m0t1fs_sb *csb)
Definition: dir.c:239
struct m0t1fs_mdop mo
Definition: dir.c:332
static int struct dentry * dentry
Definition: dir.c:589
M0_THREAD_ENTER
Definition: dir.c:336
struct m0_fop_type m0_fop_unlink_fopt
Definition: md_fops.c:55
uint32_t d_reclen
Definition: cob.h:600
struct m0_fid pver
Definition: idx_dix.c:74
static int m0t1fs_fid_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) static int m0t1fs_fid_create(struct inode *dir
struct m0_rpc_machine * m0_fop_session_machine(const struct m0_rpc_session *s)
Definition: fop.c:453
uint32_t c_cob_idx
Definition: io_fops.h:471
#define M0_ADDB2_OBJ(obj)
Definition: addb2.h:276
M0_INTERNAL int m0t1fs_ref_get_lock(struct m0t1fs_sb *csb)
Definition: super.c:722
uint32_t b_mode
Definition: md_fops.h:77
uint32_t b_mtime
Definition: md_fops.h:88
struct m0t1fs_inode * ci
Definition: dir.c:622
M0_INTERNAL struct m0_rpc_session * m0_reqh_mdpool_service_index_to_session(const struct m0_reqh *reqh, const struct m0_fid *gob_fid, uint32_t index)
Definition: reqh.c:177
struct m0_semaphore cr_sem
Definition: dir.c:59
#define m0_streq(a, b)
Definition: string.h:34
static int m0t1fs_fid_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) static int m0t1fs_fid_mkdir(struct inode *dir
struct m0_fop_cob g_body
Definition: md_fops.h:208
static int m0t1fs_ios_cob_fop_populate(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mop, struct m0_fop *fop, const struct m0_fid *cob_fid, const struct m0_fid *gob_fid, uint32_t cob_idx)
Definition: dir.c:2203
int m0t1fs_setxattr(const struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, const char *name, const void *value, size_t size, int flags) int m0t1fs_setxattr(struct dentry *dentry
int32_t rin_rc
Definition: rm.h:1446
int32_t cr_rc
Definition: dir.c:62
static struct m0_fid cob_fid
Definition: net.c:116
struct m0_fop_str l_name
Definition: md_fops.h:117
int layout_id
Definition: dir.c:331
uint64_t b_lid
Definition: md_fops.h:90
m0_fid_tassume & fid
Definition: dir.c:928
static struct dentry * m0t1fs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) static struct dentry *m0t1fs_lookup(struct inode *dir
struct m0_fop * m0_fop_get(struct m0_fop *fop)
Definition: fop.c:162
static int file_lock_acquire(struct m0_rm_incoming *rm_in, struct m0t1fs_inode *ci)
Definition: dir.c:1730
const struct m0_rpc_item_type * ri_type
Definition: item.h:200
struct m0_fid c_gobfid
Definition: io_fops.h:460
struct m0_rpc_item * ri_reply
Definition: item.h:163
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
static struct m0_fop_fsync_rep reply_data
Definition: fsync.c:67
void * m0_alloc(size_t size)
Definition: memory.c:126
static int m0t1fs_ios_cob_truncate(struct cob_req *cr, const struct m0t1fs_inode *inode, const struct m0t1fs_mdop *mop, int idx)
Definition: dir.c:2369
static int m0t1fs_fid_readdir(struct file *f, struct dir_context *ctx)
Definition: dir.c:1000
M0_INTERNAL uint32_t m0_fid_cob_device_id(const struct m0_fid *cob_fid)
Definition: fid_convert.c:81
int m0_rpc_post_sync(struct m0_fop *fop, struct m0_rpc_session *session, const struct m0_rpc_item_ops *ri_ops, m0_time_t deadline)
Definition: rpclib.c:284
struct m0_fid b_pver
Definition: md_fops.h:93
uint64_t f_container
Definition: fid.h:39
uint64_t ri_nr_sent_max
Definition: item.h:146
m0_addb2_add(M0_AVI_FS_LOOKUP, M0_ADDB2_OBJ(&M0T1FS_I(dir) ->ci_fid))
const struct file_operations m0t1fs_fid_dir_file_operations
Definition: dir.c:2557
static int struct dentry int mode
Definition: dir.c:589
M0_INTERNAL int m0t1fs_inode_layout_rebuild(struct m0t1fs_inode *ci, struct m0_fop_cob *body)
Definition: inode.c:600
M0_INTERNAL int m0t1fs_setattr(struct dentry *dentry, struct iattr *attr)
Definition: dir.c:1586
static struct super_block super_block
Definition: fsync.c:84
uint32_t b_atime
Definition: md_fops.h:87
struct m0_fop_str s_key
Definition: md_fops.h:220
int m0t1fs_mds_cob_delxattr(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2196
return dcache_splice static d_splice_alias(inode, dentry) struct dentry * m0t1fs_fid_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) static struct dentry *m0t1fs_fid_lookup(struct inode *dir
M0_INTERNAL int m0_fop_data_alloc(struct m0_fop *fop)
Definition: fop.c:71
int m0t1fs_mds_cob_create(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2126
M0_INTERNAL void m0_fop_fini(struct m0_fop *fop)
Definition: fop.c:136
static void cob_rpc_item_cb(struct m0_rpc_item *item)
Definition: dir.c:72
M0_INTERNAL int m0_fid_sscanf(const char *s, struct m0_fid *fid)
Definition: fid.c:227
M0_INTERNAL int m0t1fs_fs_conf_lock(struct m0t1fs_sb *csb)
Definition: dir.c:227
M0_INTERNAL void m0t1fs_fs_lock(struct m0t1fs_sb *csb)
Definition: super.c:105
struct m0_fid cr_pver
Definition: dir.c:64
M0_INTERNAL int m0t1fs_cob_setattr(struct inode *inode, struct m0t1fs_mdop *mo)
Definition: dir.c:2477
static int m0t1fs_fid_check(struct m0_fid *fid)
Definition: dir.c:597
static struct fdmi_ctx ctx
Definition: main.c:80
#define FID_P(f)
Definition: fid.h:77
M0_INTERNAL bool m0t1fs_fs_is_locked(const struct m0t1fs_sb *csb)
Definition: super.c:119
static int m0t1fs_readdir(struct file *f, struct dir_context *ctx) static int m0t1fs_readdir(struct file *f
M0_INTERNAL bool m0_is_cob_create_fop(const struct m0_fop *fop)
Definition: io_fops.c:950
const struct xattr_handler m0t1fs_xattr_pver
Definition: dir.c:2503
int m0t1fs_fid_removexattr(struct dentry *dentry, const char *name)
Definition: dir.c:544
struct m0_fop_str g_key
Definition: md_fops.h:209
const struct xattr_handler * m0t1fs_xattr_handlers[]
Definition: dir.c:2529
struct m0_fop_type m0_fop_listxattr_fopt
Definition: md_fops.c:63
void(* rio_replied)(struct m0_rpc_item *item)
Definition: item.h:300
struct m0_dirent * dirent_first(struct m0_fop_readdir_rep *rep)
Definition: dir.c:947
struct m0_fop_str g_value
Definition: md_fops.h:215
M0_INTERNAL int m0t1fs_cob_getattr(struct inode *inode)
Definition: dir.c:2386
static int m0t1fs_ios_cob_delete(struct cob_req *cr, const struct m0t1fs_inode *inode, const struct m0t1fs_mdop *mop, int idx)
Definition: dir.c:2361
M0_INTERNAL int m0_rpc_session_validate(struct m0_rpc_session *session)
Definition: session.c:573
m0t1fs_file_lock_init(ci, csb)
struct m0_fop_cob g_body
Definition: md_fops.h:204
static int m0t1fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) static int m0t1fs_mkdir(struct inode *dir
int32_t m0_rpc_item_error(const struct m0_rpc_item *item)
Definition: item.c:973
int m0t1fs_mds_cob_setattr(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2161
int m0t1fs_mds_statfs(struct m0t1fs_sb *csb, struct m0_fop **rep_fop)
Definition: dir.c:2119
static const struct xattr_handler m0t1fs_xattr_fid_lid
Definition: dir.c:2515
struct m0_pdclust_tgt_addr tgt
Definition: fd.c:110
M0_INTERNAL int64_t m0_layout_find_by_buffsize(struct m0_layout_domain *dom, struct m0_fid *pver, size_t buffsize)
Definition: layout.c:810
static struct super_block sb
Definition: file.c:85
uint64_t b_blocks
Definition: md_fops.h:80
M0_INTERNAL int64_t m0_ref_read(const struct m0_ref *ref)
Definition: refs.c:44
int m0t1fs_mds_cob_readdir(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2168
struct m0_fop_str s_value
Definition: md_fops.h:221
M0_INTERNAL void m0_file_unlock(struct m0_rm_incoming *req)
Definition: file.c:540
bool i_err
Definition: dir.c:630
struct m0_fop_cob s_body
Definition: md_fops.h:219
struct m0_ref f_ref
Definition: fop.h:80
Definition: fid.h:38
uint64_t b_blksize
Definition: md_fops.h:79
uint64_t f_key
Definition: fid.h:40
struct m0_fop_type m0_fop_setattr_fopt
Definition: md_fops.c:58
M0_INTERNAL void m0t1fs_inode_update(struct inode *inode, struct m0_fop_cob *body)
Definition: inode.c:389
struct m0_fop_type m0_fop_readdir_fopt
Definition: md_fops.c:66
uint64_t b_version
Definition: md_fops.h:74
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
Definition: semaphore.c:45
const struct m0_rpc_item_ops * ri_ops
Definition: item.h:149
int m0t1fs_inode_set_layout_id(struct m0t1fs_inode *ci, struct m0t1fs_mdop *mo, int layout_id)
Definition: dir.c:272
m0_time_t m0_time_from_now(uint64_t secs, long ns)
Definition: time.c:96
const struct inode_operations m0t1fs_dir_inode_operations
Definition: dir.c:2574
M0_INTERNAL bool m0t1fs_inode_is_root(const struct inode *inode)
Definition: inode.c:68
Definition: dir.c:67
Definition: addb2.c:200
uint32_t pa_P
Definition: pdclust.h:115
struct m0_rpc_session * ri_session
Definition: item.h:147
m0_time_t cr_deadline
Definition: dir.c:60
void m0t1fs_fid_alloc(struct m0t1fs_sb *csb, struct m0_fid *out)
Definition: dir.c:252
struct m0_fop_type m0_fop_cob_create_fopt
Definition: io_fops.c:75
M0_INTERNAL void * m0_bitstring_buf_get(struct m0_bitstring *c)
Definition: bitstring.c:33
struct m0_rpc_item * m0_fop_to_rpc_item(const struct m0_fop *fop)
Definition: fop.c:338
M0_ENTRY("Setting %.*s's xattr %s=%.*s", dentry->d_name.len,(char *) dentry->d_name.name, name,(int) size,(char *) value)
struct m0_fop * m0_fop_alloc_at(struct m0_rpc_session *sess, struct m0_fop_type *fopt)
Definition: fop.c:122
const struct inode_operations m0t1fs_fid_dir_inode_operations
Definition: dir.c:2592
struct m0_fop_cob l_body
Definition: md_fops.h:242
static struct m0_fop * fop
Definition: item.c:57
void m0t1fs_fid_accept(struct m0t1fs_sb *csb, const struct m0_fid *fid)
Definition: dir.c:265
d_instantiate(dentry, inode)
const struct m0_uint128 m0_rm_m0t1fs_group
Definition: inode.c:59
struct m0_fop * m0_rpc_item_to_fop(const struct m0_rpc_item *item)
Definition: fop.c:346
struct m0t1fs_filedata * fd
Definition: dir.c:1030
struct m0_fop_type m0_fop_delxattr_fopt
Definition: md_fops.c:62
M0_INTERNAL void m0_rm_owner_unlock(struct m0_rm_owner *owner)
Definition: rm.c:603
bool dcache_splice
Definition: dir.c:815
M0_INTERNAL struct m0_rpc_session * m0t1fs_container_id_to_session(const struct m0_pool_version *pver, uint64_t container_id)
Definition: super.c:166
struct m0_fid c_pver
Definition: io_fops.h:468
static int m0t1fs_fid_rmdir(struct inode *dir, struct dentry *dentry)
Definition: dir.c:1368
struct m0_fop_type m0_fop_lookup_fopt
Definition: md_fops.c:53
unlock_new_inode(inode)
struct m0_fid b_pfid
Definition: md_fops.h:91
struct inode * dir
Definition: dir.c:1028
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
Definition: semaphore.c:49
const struct xattr_handler m0t1fs_xattr_writesize
Definition: dir.c:2509
static const struct m0_rpc_item_ops cob_item_ops
Definition: dir.c:110
Definition: nucleus.c:42
M0_INTERNAL int m0t1fs_inode_test(struct inode *inode, void *opaque)
Definition: inode.c:332
uint64_t ct_size
Definition: io_fops.h:507
M0_INTERNAL void m0_fid_convert_gob2cob(const struct m0_fid *gob_fid, struct m0_fid *cob_fid, uint32_t device_id)
Definition: fid_convert.c:55
bool dotdot_filled
Definition: dir.c:1037
#define out(...)
Definition: gen.c:41
int m0t1fs_fid_getxattr(const struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size) ssize_t m0t1fs_fid_getxattr(struct dentry *dentry
M0_INTERNAL bool m0_is_cob_delete_fop(const struct m0_fop *fop)
Definition: io_fops.c:957
int type
Definition: dir.c:1031
M0_INTERNAL void m0_rm_owner_lock(struct m0_rm_owner *owner)
Definition: rm.c:592
struct m0_fid gfid
Definition: dir.c:626
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
Definition: semaphore.c:65
uint32_t s_len
Definition: string.h:71
struct m0_uint128 cr_group_id
Definition: rm.h:506
struct m0_dirent * ent
Definition: dir.c:1029
static int m0t1fs_fid_unlink(struct inode *dir, struct dentry *dentry)
Definition: dir.c:1247
M0_INTERNAL bool m0_fid_is_valid(const struct m0_fid *fid)
Definition: fid.c:96
struct m0_fop_type m0_fop_cob_truncate_fopt
Definition: io_fops.c:77
struct m0_rpc_machine * ri_rmachine
Definition: item.h:160
M0_INTERNAL void m0_dump_cob_attr(const struct m0_cob_attr *attr)
Definition: io_fops.c:132
static int m0t1fs_opendir(struct inode *inode, struct file *file)
Definition: dir.c:953
static struct m0_dtm_oper_descr reply
Definition: transmit.c:94
uint64_t f_flags
Definition: md_fops.h:266
const struct inode_operations m0t1fs_reg_inode_operations
Definition: file.c:6771
uint64_t s_session_id
Definition: session.h:309
void m0_free(void *data)
Definition: memory.c:146
const struct file_operations m0t1fs_dir_file_operations
Definition: dir.c:2539
bool dot_filled
Definition: dir.c:1036
struct m0_rpc_item f_item
Definition: fop.h:83
struct m0_fop_cob c_body
Definition: io_fops.h:456
struct m0_pdclust_attr pv_attr
Definition: pool.h:122
struct m0_fop_cob s_body
Definition: md_fops.h:187
struct m0_fop_str d_key
Definition: md_fops.h:232
uint32_t b_gid
Definition: md_fops.h:83
#define ARRAY_SIZE(a)
Definition: misc.h:45
M0_INTERNAL void m0t1fs_ref_put_lock(struct m0t1fs_sb *csb)
Definition: super.c:749
const struct file_operations m0t1fs_reg_file_operations
Definition: file.c:5602
M0_INTERNAL void m0_poolmach_gob2cob(struct m0_poolmach *pm, const struct m0_fid *gfid, uint32_t idx, struct m0_fid *cob_fid)
M0_INTERNAL int m0t1fs_size_update(struct dentry *dentry, uint64_t newsize)
Definition: dir.c:1525
Definition: fop.h:79
void m0t1fs_fsync_record_update(struct m0_reqh_service_ctx *service, struct m0t1fs_sb *csb, struct m0t1fs_inode *inode, struct m0_be_tx_remid *btr)
Definition: fsync.c:397
int m0t1fs_getxattr(const struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size) ssize_t m0t1fs_getxattr(struct dentry *dentry
#define FID_F
Definition: fid.h:75
int m0t1fs_mds_cob_listxattr(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop **rep_fop)
Definition: dir.c:2189
struct m0_fop * rep_fop
Definition: dir.c:334
static int m0t1fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) static int m0t1fs_create(struct inode *dir
M0_INTERNAL int m0t1fs_fid_setxattr(const struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, const char *name, const void *value, size_t size, int flags) M0_INTERNAL int m0t1fs_fid_setxattr(struct dentry *dentry
m0_time_t ri_deadline
Definition: item.h:141
static int m0t1fs_mds_cob_op(struct m0t1fs_sb *csb, const struct m0t1fs_mdop *mo, struct m0_fop_type *ftype, struct m0_fop **rep_fop)
Definition: dir.c:1949
struct m0_fop_type m0_fop_cob_delete_fopt
Definition: io_fops.c:76
M0_INTERNAL void m0_fid_tassume(struct m0_fid *fid, const struct m0_fid_type *ft)
Definition: fid.c:146
M0_INTERNAL struct m0_reqh_service_ctx * m0_reqh_service_ctx_from_session(struct m0_rpc_session *session)
struct m0_fop_type m0_fop_link_fopt
Definition: md_fops.c:54
static void body_mem2wire(struct m0_fop_cob *body, const struct m0_cob_attr *attr, int valid)
Definition: dir.c:158