1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#define DEBUG_SUBSYSTEM S_LLITE
30
31#include "../include/lustre/lustre_idl.h"
32#include "../include/cl_object.h"
33#include "../include/obd.h"
34#include "../include/obd_support.h"
35#include "llite_internal.h"
36#include "vvp_internal.h"
37
38static inline struct vvp_req *cl2vvp_req(const struct cl_req_slice *slice)
39{
40 return container_of0(slice, struct vvp_req, vrq_cl);
41}
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62static void vvp_req_attr_set(const struct lu_env *env,
63 const struct cl_req_slice *slice,
64 const struct cl_object *obj,
65 struct cl_req_attr *attr, u64 flags)
66{
67 struct inode *inode;
68 struct obdo *oa;
69 u32 valid_flags;
70
71 oa = attr->cra_oa;
72 inode = vvp_object_inode(obj);
73 valid_flags = OBD_MD_FLTYPE;
74
75 if (slice->crs_req->crq_type == CRT_WRITE) {
76 if (flags & OBD_MD_FLEPOCH) {
77 oa->o_valid |= OBD_MD_FLEPOCH;
78 oa->o_ioepoch = ll_i2info(inode)->lli_ioepoch;
79 valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME |
80 OBD_MD_FLUID | OBD_MD_FLGID;
81 }
82 }
83 obdo_from_inode(oa, inode, valid_flags & flags);
84 obdo_set_parent_fid(oa, &ll_i2info(inode)->lli_fid);
85 if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_INVALID_PFID))
86 oa->o_parent_oid++;
87 memcpy(attr->cra_jobid, ll_i2info(inode)->lli_jobid,
88 LUSTRE_JOBID_SIZE);
89}
90
91static void vvp_req_completion(const struct lu_env *env,
92 const struct cl_req_slice *slice, int ioret)
93{
94 struct vvp_req *vrq;
95
96 if (ioret > 0)
97 cl_stats_tally(slice->crs_dev, slice->crs_req->crq_type, ioret);
98
99 vrq = cl2vvp_req(slice);
100 kmem_cache_free(vvp_req_kmem, vrq);
101}
102
103static const struct cl_req_operations vvp_req_ops = {
104 .cro_attr_set = vvp_req_attr_set,
105 .cro_completion = vvp_req_completion
106};
107
108int vvp_req_init(const struct lu_env *env, struct cl_device *dev,
109 struct cl_req *req)
110{
111 struct vvp_req *vrq;
112 int result;
113
114 vrq = kmem_cache_zalloc(vvp_req_kmem, GFP_NOFS);
115 if (vrq) {
116 cl_req_slice_add(req, &vrq->vrq_cl, dev, &vvp_req_ops);
117 result = 0;
118 } else {
119 result = -ENOMEM;
120 }
121 return result;
122}
123