Commit | Line | Data |
---|---|---|
103b8bda JH |
1 | /* |
2 | * GPL HEADER START | |
3 | * | |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 only, | |
8 | * as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License version 2 for more details (a copy is included | |
14 | * in the LICENSE file that accompanied this code). | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * version 2 along with this program; If not, see | |
18 | * http://www.gnu.org/licenses/gpl-2.0.html | |
19 | * | |
20 | * GPL HEADER END | |
21 | */ | |
22 | /* | |
23 | * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. | |
24 | * Use is subject to license terms. | |
25 | * | |
26 | * Copyright (c) 2011, 2014, Intel Corporation. | |
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 "../include/lustre_lite.h" | |
36 | #include "llite_internal.h" | |
37 | #include "vvp_internal.h" | |
38 | ||
39 | static inline struct vvp_req *cl2vvp_req(const struct cl_req_slice *slice) | |
40 | { | |
41 | return container_of0(slice, struct vvp_req, vrq_cl); | |
42 | } | |
43 | ||
44 | /** | |
45 | * Implementation of struct cl_req_operations::cro_attr_set() for VVP | |
46 | * layer. VVP is responsible for | |
47 | * | |
48 | * - o_[mac]time | |
49 | * | |
50 | * - o_mode | |
51 | * | |
52 | * - o_parent_seq | |
53 | * | |
54 | * - o_[ug]id | |
55 | * | |
56 | * - o_parent_oid | |
57 | * | |
58 | * - o_parent_ver | |
59 | * | |
60 | * - o_ioepoch, | |
61 | * | |
62 | */ | |
e3c9078a TH |
63 | static void vvp_req_attr_set(const struct lu_env *env, |
64 | const struct cl_req_slice *slice, | |
65 | const struct cl_object *obj, | |
66 | struct cl_req_attr *attr, u64 flags) | |
103b8bda JH |
67 | { |
68 | struct inode *inode; | |
69 | struct obdo *oa; | |
70 | u32 valid_flags; | |
71 | ||
72 | oa = attr->cra_oa; | |
73 | inode = vvp_object_inode(obj); | |
74 | valid_flags = OBD_MD_FLTYPE; | |
75 | ||
76 | if (slice->crs_req->crq_type == CRT_WRITE) { | |
77 | if (flags & OBD_MD_FLEPOCH) { | |
78 | oa->o_valid |= OBD_MD_FLEPOCH; | |
79 | oa->o_ioepoch = ll_i2info(inode)->lli_ioepoch; | |
80 | valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME | | |
81 | OBD_MD_FLUID | OBD_MD_FLGID; | |
82 | } | |
83 | } | |
84 | obdo_from_inode(oa, inode, valid_flags & flags); | |
85 | obdo_set_parent_fid(oa, &ll_i2info(inode)->lli_fid); | |
66bff4ad FY |
86 | if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_INVALID_PFID)) |
87 | oa->o_parent_oid++; | |
103b8bda JH |
88 | memcpy(attr->cra_jobid, ll_i2info(inode)->lli_jobid, |
89 | JOBSTATS_JOBID_SIZE); | |
90 | } | |
91 | ||
e3c9078a TH |
92 | static void vvp_req_completion(const struct lu_env *env, |
93 | const struct cl_req_slice *slice, int ioret) | |
103b8bda JH |
94 | { |
95 | struct vvp_req *vrq; | |
96 | ||
97 | if (ioret > 0) | |
98 | cl_stats_tally(slice->crs_dev, slice->crs_req->crq_type, ioret); | |
99 | ||
100 | vrq = cl2vvp_req(slice); | |
101 | kmem_cache_free(vvp_req_kmem, vrq); | |
102 | } | |
103 | ||
104 | static const struct cl_req_operations vvp_req_ops = { | |
105 | .cro_attr_set = vvp_req_attr_set, | |
106 | .cro_completion = vvp_req_completion | |
107 | }; | |
108 | ||
109 | int vvp_req_init(const struct lu_env *env, struct cl_device *dev, | |
110 | struct cl_req *req) | |
111 | { | |
112 | struct vvp_req *vrq; | |
113 | int result; | |
114 | ||
115 | vrq = kmem_cache_zalloc(vvp_req_kmem, GFP_NOFS); | |
116 | if (vrq) { | |
117 | cl_req_slice_add(req, &vrq->vrq_cl, dev, &vvp_req_ops); | |
118 | result = 0; | |
119 | } else { | |
120 | result = -ENOMEM; | |
121 | } | |
122 | return result; | |
123 | } |