Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2005, 2006 |
Boaz Harrosh | 27d2e14 | 2009-06-14 17:23:09 +0300 | [diff] [blame] | 3 | * Avishay Traeger (avishay@gmail.com) |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 4 | * Copyright (C) 2008, 2009 |
| 5 | * Boaz Harrosh <bharrosh@panasas.com> |
| 6 | * |
| 7 | * This file is part of exofs. |
| 8 | * |
| 9 | * exofs is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation. Since it is based on ext2, and the only |
| 12 | * valid version of GPL for the Linux kernel is version 2, the only valid |
| 13 | * version of GPL for exofs is version 2. |
| 14 | * |
| 15 | * exofs is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with exofs; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 | */ |
| 24 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | #include <linux/slab.h> |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 26 | #include <asm/div64.h> |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 27 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 28 | #include <scsi/osd_ore.h> |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 29 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 30 | #define ORE_ERR(fmt, a...) printk(KERN_ERR "ore: " fmt, ##a) |
Boaz Harrosh | 34ce4e7c | 2009-12-15 19:34:17 +0200 | [diff] [blame] | 31 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 32 | #ifdef CONFIG_EXOFS_DEBUG |
| 33 | #define ORE_DBGMSG(fmt, a...) \ |
| 34 | printk(KERN_NOTICE "ore @%s:%d: " fmt, __func__, __LINE__, ##a) |
| 35 | #else |
| 36 | #define ORE_DBGMSG(fmt, a...) \ |
| 37 | do { if (0) printk(fmt, ##a); } while (0) |
| 38 | #endif |
| 39 | |
| 40 | /* u64 has problems with printk this will cast it to unsigned long long */ |
| 41 | #define _LLU(x) (unsigned long long)(x) |
| 42 | |
| 43 | #define ORE_DBGMSG2(M...) do {} while (0) |
| 44 | /* #define ORE_DBGMSG2 ORE_DBGMSG */ |
| 45 | |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 46 | MODULE_AUTHOR("Boaz Harrosh <bharrosh@panasas.com>"); |
| 47 | MODULE_DESCRIPTION("Objects Raid Engine ore.ko"); |
| 48 | MODULE_LICENSE("GPL"); |
| 49 | |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 50 | static void ore_calc_stripe_info(struct ore_layout *layout, u64 file_offset, |
| 51 | struct ore_striping_info *si); |
| 52 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 53 | static u8 *_ios_cred(struct ore_io_state *ios, unsigned index) |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 54 | { |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 55 | return ios->oc->comps[index & ios->oc->single_comp].cred; |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 58 | static struct osd_obj_id *_ios_obj(struct ore_io_state *ios, unsigned index) |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 59 | { |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 60 | return &ios->oc->comps[index & ios->oc->single_comp].obj; |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 63 | static struct osd_dev *_ios_od(struct ore_io_state *ios, unsigned index) |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 64 | { |
Boaz Harrosh | d866d87 | 2011-09-28 14:43:09 +0300 | [diff] [blame] | 65 | return ore_comp_dev(ios->oc, index); |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 68 | static int _get_io_state(struct ore_layout *layout, |
| 69 | struct ore_components *oc, unsigned numdevs, |
| 70 | struct ore_io_state **pios) |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 71 | { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 72 | struct ore_io_state *ios; |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 73 | |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 74 | /*TODO: Maybe use kmem_cach per sbi of size |
Boaz Harrosh | 45d3abc | 2010-01-28 11:46:16 +0200 | [diff] [blame] | 75 | * exofs_io_state_size(layout->s_numdevs) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 76 | */ |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 77 | ios = kzalloc(ore_io_state_size(numdevs), GFP_KERNEL); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 78 | if (unlikely(!ios)) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 79 | ORE_DBGMSG("Failed kzalloc bytes=%d\n", |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 80 | ore_io_state_size(numdevs)); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 81 | *pios = NULL; |
| 82 | return -ENOMEM; |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 83 | } |
| 84 | |
Boaz Harrosh | 45d3abc | 2010-01-28 11:46:16 +0200 | [diff] [blame] | 85 | ios->layout = layout; |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 86 | ios->oc = oc; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 87 | *pios = ios; |
| 88 | return 0; |
| 89 | } |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 90 | |
| 91 | /* Allocate an io_state for only a single group of devices |
| 92 | * |
| 93 | * If a user needs to call ore_read/write() this version must be used becase it |
| 94 | * allocates extra stuff for striping and raid. |
| 95 | * The ore might decide to only IO less then @length bytes do to alignmets |
| 96 | * and constrains as follows: |
| 97 | * - The IO cannot cross group boundary. |
| 98 | * - In raid5/6 The end of the IO must align at end of a stripe eg. |
| 99 | * (@offset + @length) % strip_size == 0. Or the complete range is within a |
| 100 | * single stripe. |
| 101 | * - Memory condition only permitted a shorter IO. (A user can use @length=~0 |
| 102 | * And check the returned ios->length for max_io_size.) |
| 103 | * |
| 104 | * The caller must check returned ios->length (and/or ios->nr_pages) and |
| 105 | * re-issue these pages that fall outside of ios->length |
| 106 | */ |
| 107 | int ore_get_rw_state(struct ore_layout *layout, struct ore_components *oc, |
| 108 | bool is_reading, u64 offset, u64 length, |
| 109 | struct ore_io_state **pios) |
| 110 | { |
| 111 | struct ore_io_state *ios; |
| 112 | unsigned numdevs = layout->group_width * layout->mirrors_p1; |
| 113 | int ret; |
| 114 | |
| 115 | ret = _get_io_state(layout, oc, numdevs, pios); |
| 116 | if (unlikely(ret)) |
| 117 | return ret; |
| 118 | |
| 119 | ios = *pios; |
| 120 | ios->reading = is_reading; |
| 121 | ios->offset = offset; |
| 122 | |
| 123 | if (length) { |
Boaz Harrosh | 9826075 | 2011-10-02 15:32:50 +0200 | [diff] [blame^] | 124 | ore_calc_stripe_info(layout, offset, &ios->si); |
| 125 | ios->length = (length <= ios->si.group_length) ? length : |
| 126 | ios->si.group_length; |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 127 | ios->nr_pages = (ios->length + PAGE_SIZE - 1) / PAGE_SIZE; |
| 128 | } |
| 129 | |
| 130 | return 0; |
| 131 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 132 | EXPORT_SYMBOL(ore_get_rw_state); |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 133 | |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 134 | /* Allocate an io_state for all the devices in the comps array |
| 135 | * |
| 136 | * This version of io_state allocation is used mostly by create/remove |
| 137 | * and trunc where we currently need all the devices. The only wastful |
| 138 | * bit is the read/write_attributes with no IO. Those sites should |
| 139 | * be converted to use ore_get_rw_state() with length=0 |
| 140 | */ |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 141 | int ore_get_io_state(struct ore_layout *layout, struct ore_components *oc, |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 142 | struct ore_io_state **pios) |
Boaz Harrosh | e1042ba | 2010-11-16 20:09:58 +0200 | [diff] [blame] | 143 | { |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 144 | return _get_io_state(layout, oc, oc->numdevs, pios); |
Boaz Harrosh | e1042ba | 2010-11-16 20:09:58 +0200 | [diff] [blame] | 145 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 146 | EXPORT_SYMBOL(ore_get_io_state); |
Boaz Harrosh | e1042ba | 2010-11-16 20:09:58 +0200 | [diff] [blame] | 147 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 148 | void ore_put_io_state(struct ore_io_state *ios) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 149 | { |
| 150 | if (ios) { |
| 151 | unsigned i; |
| 152 | |
| 153 | for (i = 0; i < ios->numdevs; i++) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 154 | struct ore_per_dev_state *per_dev = &ios->per_dev[i]; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 155 | |
| 156 | if (per_dev->or) |
| 157 | osd_end_request(per_dev->or); |
| 158 | if (per_dev->bio) |
| 159 | bio_put(per_dev->bio); |
| 160 | } |
| 161 | |
| 162 | kfree(ios); |
| 163 | } |
| 164 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 165 | EXPORT_SYMBOL(ore_put_io_state); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 166 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 167 | static void _sync_done(struct ore_io_state *ios, void *p) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 168 | { |
| 169 | struct completion *waiting = p; |
| 170 | |
| 171 | complete(waiting); |
| 172 | } |
| 173 | |
| 174 | static void _last_io(struct kref *kref) |
| 175 | { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 176 | struct ore_io_state *ios = container_of( |
| 177 | kref, struct ore_io_state, kref); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 178 | |
| 179 | ios->done(ios, ios->private); |
| 180 | } |
| 181 | |
| 182 | static void _done_io(struct osd_request *or, void *p) |
| 183 | { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 184 | struct ore_io_state *ios = p; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 185 | |
| 186 | kref_put(&ios->kref, _last_io); |
| 187 | } |
| 188 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 189 | static int ore_io_execute(struct ore_io_state *ios) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 190 | { |
| 191 | DECLARE_COMPLETION_ONSTACK(wait); |
| 192 | bool sync = (ios->done == NULL); |
| 193 | int i, ret; |
| 194 | |
| 195 | if (sync) { |
| 196 | ios->done = _sync_done; |
| 197 | ios->private = &wait; |
| 198 | } |
| 199 | |
| 200 | for (i = 0; i < ios->numdevs; i++) { |
| 201 | struct osd_request *or = ios->per_dev[i].or; |
| 202 | if (unlikely(!or)) |
| 203 | continue; |
| 204 | |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 205 | ret = osd_finalize_request(or, 0, _ios_cred(ios, i), NULL); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 206 | if (unlikely(ret)) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 207 | ORE_DBGMSG("Failed to osd_finalize_request() => %d\n", |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 208 | ret); |
| 209 | return ret; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | kref_init(&ios->kref); |
| 214 | |
| 215 | for (i = 0; i < ios->numdevs; i++) { |
| 216 | struct osd_request *or = ios->per_dev[i].or; |
| 217 | if (unlikely(!or)) |
| 218 | continue; |
| 219 | |
| 220 | kref_get(&ios->kref); |
| 221 | osd_execute_request_async(or, _done_io, ios); |
| 222 | } |
| 223 | |
| 224 | kref_put(&ios->kref, _last_io); |
| 225 | ret = 0; |
| 226 | |
| 227 | if (sync) { |
| 228 | wait_for_completion(&wait); |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 229 | ret = ore_check_io(ios, NULL); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 230 | } |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 231 | return ret; |
| 232 | } |
| 233 | |
Boaz Harrosh | 22ddc55 | 2010-01-19 19:24:45 +0200 | [diff] [blame] | 234 | static void _clear_bio(struct bio *bio) |
| 235 | { |
| 236 | struct bio_vec *bv; |
| 237 | unsigned i; |
| 238 | |
| 239 | __bio_for_each_segment(bv, bio, i, 0) { |
| 240 | unsigned this_count = bv->bv_len; |
| 241 | |
| 242 | if (likely(PAGE_SIZE == this_count)) |
| 243 | clear_highpage(bv->bv_page); |
| 244 | else |
| 245 | zero_user(bv->bv_page, bv->bv_offset, this_count); |
| 246 | } |
| 247 | } |
| 248 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 249 | int ore_check_io(struct ore_io_state *ios, u64 *resid) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 250 | { |
| 251 | enum osd_err_priority acumulated_osd_err = 0; |
| 252 | int acumulated_lin_err = 0; |
| 253 | int i; |
| 254 | |
| 255 | for (i = 0; i < ios->numdevs; i++) { |
| 256 | struct osd_sense_info osi; |
Boaz Harrosh | 22ddc55 | 2010-01-19 19:24:45 +0200 | [diff] [blame] | 257 | struct osd_request *or = ios->per_dev[i].or; |
| 258 | int ret; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 259 | |
Boaz Harrosh | 22ddc55 | 2010-01-19 19:24:45 +0200 | [diff] [blame] | 260 | if (unlikely(!or)) |
| 261 | continue; |
| 262 | |
| 263 | ret = osd_req_decode_sense(or, &osi); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 264 | if (likely(!ret)) |
| 265 | continue; |
| 266 | |
Boaz Harrosh | 22ddc55 | 2010-01-19 19:24:45 +0200 | [diff] [blame] | 267 | if (OSD_ERR_PRI_CLEAR_PAGES == osi.osd_err_pri) { |
| 268 | /* start read offset passed endof file */ |
| 269 | _clear_bio(ios->per_dev[i].bio); |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 270 | ORE_DBGMSG("start read offset passed end of file " |
Boaz Harrosh | 22ddc55 | 2010-01-19 19:24:45 +0200 | [diff] [blame] | 271 | "offset=0x%llx, length=0x%llx\n", |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 272 | _LLU(ios->per_dev[i].offset), |
| 273 | _LLU(ios->per_dev[i].length)); |
Boaz Harrosh | 22ddc55 | 2010-01-19 19:24:45 +0200 | [diff] [blame] | 274 | |
| 275 | continue; /* we recovered */ |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | if (osi.osd_err_pri >= acumulated_osd_err) { |
| 279 | acumulated_osd_err = osi.osd_err_pri; |
| 280 | acumulated_lin_err = ret; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | /* TODO: raid specific residual calculations */ |
| 285 | if (resid) { |
| 286 | if (likely(!acumulated_lin_err)) |
| 287 | *resid = 0; |
| 288 | else |
| 289 | *resid = ios->length; |
| 290 | } |
| 291 | |
| 292 | return acumulated_lin_err; |
| 293 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 294 | EXPORT_SYMBOL(ore_check_io); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 295 | |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 296 | /* |
| 297 | * L - logical offset into the file |
| 298 | * |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 299 | * U - The number of bytes in a stripe within a group |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 300 | * |
| 301 | * U = stripe_unit * group_width |
| 302 | * |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 303 | * T - The number of bytes striped within a group of component objects |
| 304 | * (before advancing to the next group) |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 305 | * |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 306 | * T = stripe_unit * group_width * group_depth |
| 307 | * |
| 308 | * S - The number of bytes striped across all component objects |
| 309 | * before the pattern repeats |
| 310 | * |
| 311 | * S = stripe_unit * group_width * group_depth * group_count |
| 312 | * |
| 313 | * M - The "major" (i.e., across all components) stripe number |
| 314 | * |
| 315 | * M = L / S |
| 316 | * |
| 317 | * G - Counts the groups from the beginning of the major stripe |
| 318 | * |
| 319 | * G = (L - (M * S)) / T [or (L % S) / T] |
| 320 | * |
| 321 | * H - The byte offset within the group |
| 322 | * |
| 323 | * H = (L - (M * S)) % T [or (L % S) % T] |
| 324 | * |
| 325 | * N - The "minor" (i.e., across the group) stripe number |
| 326 | * |
| 327 | * N = H / U |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 328 | * |
| 329 | * C - The component index coresponding to L |
| 330 | * |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 331 | * C = (H - (N * U)) / stripe_unit + G * group_width |
| 332 | * [or (L % U) / stripe_unit + G * group_width] |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 333 | * |
| 334 | * O - The component offset coresponding to L |
| 335 | * |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 336 | * O = L % stripe_unit + N * stripe_unit + M * group_depth * stripe_unit |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 337 | */ |
Boaz Harrosh | eb507bc | 2011-08-10 14:17:28 -0700 | [diff] [blame] | 338 | static void ore_calc_stripe_info(struct ore_layout *layout, u64 file_offset, |
| 339 | struct ore_striping_info *si) |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 340 | { |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 341 | u32 stripe_unit = layout->stripe_unit; |
| 342 | u32 group_width = layout->group_width; |
| 343 | u64 group_depth = layout->group_depth; |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 344 | |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 345 | u32 U = stripe_unit * group_width; |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 346 | u64 T = U * group_depth; |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 347 | u64 S = T * layout->group_count; |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 348 | u64 M = div64_u64(file_offset, S); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 349 | |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 350 | /* |
| 351 | G = (L - (M * S)) / T |
| 352 | H = (L - (M * S)) % T |
| 353 | */ |
| 354 | u64 LmodS = file_offset - M * S; |
| 355 | u32 G = div64_u64(LmodS, T); |
| 356 | u64 H = LmodS - G * T; |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 357 | |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 358 | u32 N = div_u64(H, U); |
| 359 | |
| 360 | /* "H - (N * U)" is just "H % U" so it's bound to u32 */ |
| 361 | si->dev = (u32)(H - (N * U)) / stripe_unit + G * group_width; |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 362 | si->dev *= layout->mirrors_p1; |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 363 | |
| 364 | div_u64_rem(file_offset, stripe_unit, &si->unit_off); |
| 365 | |
| 366 | si->obj_offset = si->unit_off + (N * stripe_unit) + |
| 367 | (M * group_depth * stripe_unit); |
| 368 | |
| 369 | si->group_length = T - H; |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 370 | si->M = M; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 371 | } |
| 372 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 373 | static int _add_stripe_unit(struct ore_io_state *ios, unsigned *cur_pg, |
| 374 | unsigned pgbase, struct ore_per_dev_state *per_dev, |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 375 | int cur_len) |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 376 | { |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 377 | unsigned pg = *cur_pg; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 378 | struct request_queue *q = |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 379 | osd_request_queue(_ios_od(ios, per_dev->dev)); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 380 | |
| 381 | per_dev->length += cur_len; |
| 382 | |
| 383 | if (per_dev->bio == NULL) { |
| 384 | unsigned pages_in_stripe = ios->layout->group_width * |
| 385 | (ios->layout->stripe_unit / PAGE_SIZE); |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 386 | unsigned bio_size = (ios->nr_pages + pages_in_stripe) / |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 387 | ios->layout->group_width; |
| 388 | |
| 389 | per_dev->bio = bio_kmalloc(GFP_KERNEL, bio_size); |
| 390 | if (unlikely(!per_dev->bio)) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 391 | ORE_DBGMSG("Failed to allocate BIO size=%u\n", |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 392 | bio_size); |
| 393 | return -ENOMEM; |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | while (cur_len > 0) { |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 398 | unsigned pglen = min_t(unsigned, PAGE_SIZE - pgbase, cur_len); |
| 399 | unsigned added_len; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 400 | |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 401 | BUG_ON(ios->nr_pages <= pg); |
| 402 | cur_len -= pglen; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 403 | |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 404 | added_len = bio_add_pc_page(q, per_dev->bio, ios->pages[pg], |
| 405 | pglen, pgbase); |
| 406 | if (unlikely(pglen != added_len)) |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 407 | return -ENOMEM; |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 408 | pgbase = 0; |
| 409 | ++pg; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 410 | } |
| 411 | BUG_ON(cur_len); |
| 412 | |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 413 | *cur_pg = pg; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 414 | return 0; |
| 415 | } |
| 416 | |
Boaz Harrosh | 9826075 | 2011-10-02 15:32:50 +0200 | [diff] [blame^] | 417 | static int _prepare_for_striping(struct ore_io_state *ios) |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 418 | { |
Boaz Harrosh | 9826075 | 2011-10-02 15:32:50 +0200 | [diff] [blame^] | 419 | struct ore_striping_info *si = &ios->si; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 420 | unsigned stripe_unit = ios->layout->stripe_unit; |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 421 | unsigned mirrors_p1 = ios->layout->mirrors_p1; |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 422 | unsigned devs_in_group = ios->layout->group_width * mirrors_p1; |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 423 | unsigned dev = si->dev; |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 424 | unsigned first_dev = dev - (dev % devs_in_group); |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 425 | unsigned cur_pg = ios->pages_consumed; |
Boaz Harrosh | 9826075 | 2011-10-02 15:32:50 +0200 | [diff] [blame^] | 426 | u64 length = ios->length; |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 427 | int ret = 0; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 428 | |
Boaz Harrosh | 9826075 | 2011-10-02 15:32:50 +0200 | [diff] [blame^] | 429 | if (!ios->pages) { |
| 430 | if (ios->kern_buff) { |
| 431 | struct ore_per_dev_state *per_dev = &ios->per_dev[0]; |
| 432 | |
| 433 | per_dev->offset = si->obj_offset; |
| 434 | per_dev->dev = si->dev; |
| 435 | |
| 436 | /* no cross device without page array */ |
| 437 | BUG_ON((ios->layout->group_width > 1) && |
| 438 | (si->unit_off + ios->length > |
| 439 | ios->layout->stripe_unit)); |
| 440 | } |
| 441 | ios->numdevs = ios->layout->mirrors_p1; |
| 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | BUG_ON(length > si->group_length); |
| 446 | |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 447 | while (length) { |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 448 | unsigned comp = dev - first_dev; |
| 449 | struct ore_per_dev_state *per_dev = &ios->per_dev[comp]; |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 450 | unsigned cur_len, page_off = 0; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 451 | |
| 452 | if (!per_dev->length) { |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 453 | per_dev->dev = dev; |
| 454 | if (dev < si->dev) { |
| 455 | per_dev->offset = si->obj_offset + stripe_unit - |
| 456 | si->unit_off; |
| 457 | cur_len = stripe_unit; |
| 458 | } else if (dev == si->dev) { |
| 459 | per_dev->offset = si->obj_offset; |
| 460 | cur_len = stripe_unit - si->unit_off; |
| 461 | page_off = si->unit_off & ~PAGE_MASK; |
| 462 | BUG_ON(page_off && (page_off != ios->pgbase)); |
| 463 | } else { /* dev > si->dev */ |
| 464 | per_dev->offset = si->obj_offset - si->unit_off; |
| 465 | cur_len = stripe_unit; |
| 466 | } |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 467 | } else { |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 468 | cur_len = stripe_unit; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 469 | } |
Boaz Harrosh | b367e78 | 2010-02-07 19:18:58 +0200 | [diff] [blame] | 470 | if (cur_len >= length) |
| 471 | cur_len = length; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 472 | |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 473 | ret = _add_stripe_unit(ios, &cur_pg, page_off , per_dev, |
| 474 | cur_len); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 475 | if (unlikely(ret)) |
| 476 | goto out; |
| 477 | |
Boaz Harrosh | 6e31609 | 2010-07-29 17:08:13 +0300 | [diff] [blame] | 478 | dev += mirrors_p1; |
| 479 | dev = (dev % devs_in_group) + first_dev; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 480 | |
| 481 | length -= cur_len; |
| 482 | } |
| 483 | out: |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 484 | ios->numdevs = devs_in_group; |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 485 | ios->pages_consumed = cur_pg; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 486 | return ret; |
| 487 | } |
| 488 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 489 | int ore_create(struct ore_io_state *ios) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 490 | { |
| 491 | int i, ret; |
| 492 | |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 493 | for (i = 0; i < ios->oc->numdevs; i++) { |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 494 | struct osd_request *or; |
| 495 | |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 496 | or = osd_start_request(_ios_od(ios, i), GFP_KERNEL); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 497 | if (unlikely(!or)) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 498 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 499 | ret = -ENOMEM; |
| 500 | goto out; |
| 501 | } |
| 502 | ios->per_dev[i].or = or; |
| 503 | ios->numdevs++; |
| 504 | |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 505 | osd_req_create_object(or, _ios_obj(ios, i)); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 506 | } |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 507 | ret = ore_io_execute(ios); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 508 | |
| 509 | out: |
| 510 | return ret; |
| 511 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 512 | EXPORT_SYMBOL(ore_create); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 513 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 514 | int ore_remove(struct ore_io_state *ios) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 515 | { |
| 516 | int i, ret; |
| 517 | |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 518 | for (i = 0; i < ios->oc->numdevs; i++) { |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 519 | struct osd_request *or; |
| 520 | |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 521 | or = osd_start_request(_ios_od(ios, i), GFP_KERNEL); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 522 | if (unlikely(!or)) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 523 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 524 | ret = -ENOMEM; |
| 525 | goto out; |
| 526 | } |
| 527 | ios->per_dev[i].or = or; |
| 528 | ios->numdevs++; |
| 529 | |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 530 | osd_req_remove_object(or, _ios_obj(ios, i)); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 531 | } |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 532 | ret = ore_io_execute(ios); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 533 | |
| 534 | out: |
| 535 | return ret; |
| 536 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 537 | EXPORT_SYMBOL(ore_remove); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 538 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 539 | static int _write_mirror(struct ore_io_state *ios, int cur_comp) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 540 | { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 541 | struct ore_per_dev_state *master_dev = &ios->per_dev[cur_comp]; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 542 | unsigned dev = ios->per_dev[cur_comp].dev; |
| 543 | unsigned last_comp = cur_comp + ios->layout->mirrors_p1; |
| 544 | int ret = 0; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 545 | |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 546 | if (ios->pages && !master_dev->length) |
| 547 | return 0; /* Just an empty slot */ |
| 548 | |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 549 | for (; cur_comp < last_comp; ++cur_comp, ++dev) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 550 | struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp]; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 551 | struct osd_request *or; |
| 552 | |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 553 | or = osd_start_request(_ios_od(ios, dev), GFP_KERNEL); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 554 | if (unlikely(!or)) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 555 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 556 | ret = -ENOMEM; |
| 557 | goto out; |
| 558 | } |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 559 | per_dev->or = or; |
| 560 | per_dev->offset = master_dev->offset; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 561 | |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 562 | if (ios->pages) { |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 563 | struct bio *bio; |
| 564 | |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 565 | if (per_dev != master_dev) { |
Boaz Harrosh | 04dc1e8 | 2009-11-16 16:03:05 +0200 | [diff] [blame] | 566 | bio = bio_kmalloc(GFP_KERNEL, |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 567 | master_dev->bio->bi_max_vecs); |
Boaz Harrosh | 04dc1e8 | 2009-11-16 16:03:05 +0200 | [diff] [blame] | 568 | if (unlikely(!bio)) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 569 | ORE_DBGMSG( |
Paul Bolle | 426d310 | 2010-08-07 12:30:03 +0200 | [diff] [blame] | 570 | "Failed to allocate BIO size=%u\n", |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 571 | master_dev->bio->bi_max_vecs); |
Boaz Harrosh | 04dc1e8 | 2009-11-16 16:03:05 +0200 | [diff] [blame] | 572 | ret = -ENOMEM; |
| 573 | goto out; |
| 574 | } |
| 575 | |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 576 | __bio_clone(bio, master_dev->bio); |
Boaz Harrosh | 04dc1e8 | 2009-11-16 16:03:05 +0200 | [diff] [blame] | 577 | bio->bi_bdev = NULL; |
| 578 | bio->bi_next = NULL; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 579 | per_dev->length = master_dev->length; |
| 580 | per_dev->bio = bio; |
| 581 | per_dev->dev = dev; |
Boaz Harrosh | 04dc1e8 | 2009-11-16 16:03:05 +0200 | [diff] [blame] | 582 | } else { |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 583 | bio = master_dev->bio; |
| 584 | /* FIXME: bio_set_dir() */ |
Christoph Hellwig | 7b6d91d | 2010-08-07 18:20:39 +0200 | [diff] [blame] | 585 | bio->bi_rw |= REQ_WRITE; |
Boaz Harrosh | 04dc1e8 | 2009-11-16 16:03:05 +0200 | [diff] [blame] | 586 | } |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 587 | |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 588 | osd_req_write(or, _ios_obj(ios, dev), per_dev->offset, |
| 589 | bio, per_dev->length); |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 590 | ORE_DBGMSG("write(0x%llx) offset=0x%llx " |
Boaz Harrosh | 34ce4e7c | 2009-12-15 19:34:17 +0200 | [diff] [blame] | 591 | "length=0x%llx dev=%d\n", |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 592 | _LLU(_ios_obj(ios, dev)->id), |
| 593 | _LLU(per_dev->offset), |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 594 | _LLU(per_dev->length), dev); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 595 | } else if (ios->kern_buff) { |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 596 | ret = osd_req_write_kern(or, _ios_obj(ios, dev), |
| 597 | per_dev->offset, |
| 598 | ios->kern_buff, ios->length); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 599 | if (unlikely(ret)) |
| 600 | goto out; |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 601 | ORE_DBGMSG2("write_kern(0x%llx) offset=0x%llx " |
Boaz Harrosh | 34ce4e7c | 2009-12-15 19:34:17 +0200 | [diff] [blame] | 602 | "length=0x%llx dev=%d\n", |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 603 | _LLU(_ios_obj(ios, dev)->id), |
| 604 | _LLU(per_dev->offset), |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 605 | _LLU(ios->length), dev); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 606 | } else { |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 607 | osd_req_set_attributes(or, _ios_obj(ios, dev)); |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 608 | ORE_DBGMSG2("obj(0x%llx) set_attributes=%d dev=%d\n", |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 609 | _LLU(_ios_obj(ios, dev)->id), |
| 610 | ios->out_attr_len, dev); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | if (ios->out_attr) |
| 614 | osd_req_add_set_attr_list(or, ios->out_attr, |
| 615 | ios->out_attr_len); |
| 616 | |
| 617 | if (ios->in_attr) |
| 618 | osd_req_add_get_attr_list(or, ios->in_attr, |
| 619 | ios->in_attr_len); |
| 620 | } |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 621 | |
| 622 | out: |
| 623 | return ret; |
| 624 | } |
| 625 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 626 | int ore_write(struct ore_io_state *ios) |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 627 | { |
| 628 | int i; |
| 629 | int ret; |
| 630 | |
| 631 | ret = _prepare_for_striping(ios); |
| 632 | if (unlikely(ret)) |
| 633 | return ret; |
| 634 | |
| 635 | for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 636 | ret = _write_mirror(ios, i); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 637 | if (unlikely(ret)) |
| 638 | return ret; |
| 639 | } |
| 640 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 641 | ret = ore_io_execute(ios); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 642 | return ret; |
| 643 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 644 | EXPORT_SYMBOL(ore_write); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 645 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 646 | static int _read_mirror(struct ore_io_state *ios, unsigned cur_comp) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 647 | { |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 648 | struct osd_request *or; |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 649 | struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp]; |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 650 | struct osd_obj_id *obj = _ios_obj(ios, cur_comp); |
| 651 | unsigned first_dev = (unsigned)obj->id; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 652 | |
Boaz Harrosh | 50a76fd | 2010-02-11 13:01:39 +0200 | [diff] [blame] | 653 | if (ios->pages && !per_dev->length) |
| 654 | return 0; /* Just an empty slot */ |
| 655 | |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 656 | first_dev = per_dev->dev + first_dev % ios->layout->mirrors_p1; |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 657 | or = osd_start_request(_ios_od(ios, first_dev), GFP_KERNEL); |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 658 | if (unlikely(!or)) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 659 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 660 | return -ENOMEM; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 661 | } |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 662 | per_dev->or = or; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 663 | |
Boaz Harrosh | 86093aa | 2010-01-28 18:24:06 +0200 | [diff] [blame] | 664 | if (ios->pages) { |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 665 | osd_req_read(or, obj, per_dev->offset, |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 666 | per_dev->bio, per_dev->length); |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 667 | ORE_DBGMSG("read(0x%llx) offset=0x%llx length=0x%llx" |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 668 | " dev=%d\n", _LLU(obj->id), |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 669 | _LLU(per_dev->offset), _LLU(per_dev->length), |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 670 | first_dev); |
| 671 | } else if (ios->kern_buff) { |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 672 | int ret = osd_req_read_kern(or, obj, per_dev->offset, |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 673 | ios->kern_buff, ios->length); |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 674 | ORE_DBGMSG2("read_kern(0x%llx) offset=0x%llx " |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 675 | "length=0x%llx dev=%d ret=>%d\n", |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 676 | _LLU(obj->id), _LLU(per_dev->offset), |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 677 | _LLU(ios->length), first_dev, ret); |
| 678 | if (unlikely(ret)) |
| 679 | return ret; |
| 680 | } else { |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 681 | osd_req_get_attributes(or, obj); |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 682 | ORE_DBGMSG2("obj(0x%llx) get_attributes=%d dev=%d\n", |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 683 | _LLU(obj->id), |
| 684 | ios->in_attr_len, first_dev); |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 685 | } |
Boaz Harrosh | 46f4d97 | 2010-02-01 11:37:30 +0200 | [diff] [blame] | 686 | if (ios->out_attr) |
| 687 | osd_req_add_set_attr_list(or, ios->out_attr, ios->out_attr_len); |
| 688 | |
| 689 | if (ios->in_attr) |
| 690 | osd_req_add_get_attr_list(or, ios->in_attr, ios->in_attr_len); |
| 691 | |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 692 | return 0; |
| 693 | } |
| 694 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 695 | int ore_read(struct ore_io_state *ios) |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 696 | { |
| 697 | int i; |
| 698 | int ret; |
| 699 | |
| 700 | ret = _prepare_for_striping(ios); |
| 701 | if (unlikely(ret)) |
| 702 | return ret; |
| 703 | |
| 704 | for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 705 | ret = _read_mirror(ios, i); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 706 | if (unlikely(ret)) |
| 707 | return ret; |
| 708 | } |
| 709 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 710 | ret = ore_io_execute(ios); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 711 | return ret; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 712 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 713 | EXPORT_SYMBOL(ore_read); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 714 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 715 | int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr) |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 716 | { |
| 717 | struct osd_attr cur_attr = {.attr_page = 0}; /* start with zeros */ |
| 718 | void *iter = NULL; |
| 719 | int nelem; |
| 720 | |
| 721 | do { |
| 722 | nelem = 1; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 723 | osd_req_decode_get_attr_list(ios->per_dev[0].or, |
| 724 | &cur_attr, &nelem, &iter); |
Boaz Harrosh | b14f8ab | 2008-10-27 18:27:55 +0200 | [diff] [blame] | 725 | if ((cur_attr.attr_page == attr->attr_page) && |
| 726 | (cur_attr.attr_id == attr->attr_id)) { |
| 727 | attr->len = cur_attr.len; |
| 728 | attr->val_ptr = cur_attr.val_ptr; |
| 729 | return 0; |
| 730 | } |
| 731 | } while (iter); |
| 732 | |
| 733 | return -EIO; |
| 734 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 735 | EXPORT_SYMBOL(extract_attr_from_ios); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 736 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 737 | static int _truncate_mirrors(struct ore_io_state *ios, unsigned cur_comp, |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 738 | struct osd_attr *attr) |
| 739 | { |
| 740 | int last_comp = cur_comp + ios->layout->mirrors_p1; |
| 741 | |
| 742 | for (; cur_comp < last_comp; ++cur_comp) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 743 | struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp]; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 744 | struct osd_request *or; |
| 745 | |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 746 | or = osd_start_request(_ios_od(ios, cur_comp), GFP_KERNEL); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 747 | if (unlikely(!or)) { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 748 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 749 | return -ENOMEM; |
| 750 | } |
| 751 | per_dev->or = or; |
| 752 | |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 753 | osd_req_set_attributes(or, _ios_obj(ios, cur_comp)); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 754 | osd_req_add_set_attr_list(or, attr, 1); |
| 755 | } |
| 756 | |
| 757 | return 0; |
| 758 | } |
| 759 | |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 760 | struct _trunc_info { |
Boaz Harrosh | eb507bc | 2011-08-10 14:17:28 -0700 | [diff] [blame] | 761 | struct ore_striping_info si; |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 762 | u64 prev_group_obj_off; |
| 763 | u64 next_group_obj_off; |
| 764 | |
| 765 | unsigned first_group_dev; |
| 766 | unsigned nex_group_dev; |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 767 | }; |
| 768 | |
H Hartley Sweeten | 1958c7c2 | 2011-09-23 13:42:43 -0700 | [diff] [blame] | 769 | static void _calc_trunk_info(struct ore_layout *layout, u64 file_offset, |
| 770 | struct _trunc_info *ti) |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 771 | { |
| 772 | unsigned stripe_unit = layout->stripe_unit; |
| 773 | |
Boaz Harrosh | eb507bc | 2011-08-10 14:17:28 -0700 | [diff] [blame] | 774 | ore_calc_stripe_info(layout, file_offset, &ti->si); |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 775 | |
| 776 | ti->prev_group_obj_off = ti->si.M * stripe_unit; |
| 777 | ti->next_group_obj_off = ti->si.M ? (ti->si.M - 1) * stripe_unit : 0; |
| 778 | |
| 779 | ti->first_group_dev = ti->si.dev - (ti->si.dev % layout->group_width); |
| 780 | ti->nex_group_dev = ti->first_group_dev + layout->group_width; |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 781 | } |
| 782 | |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 783 | int ore_truncate(struct ore_layout *layout, struct ore_components *oc, |
Boaz Harrosh | 9e9db45 | 2011-08-05 15:06:04 -0700 | [diff] [blame] | 784 | u64 size) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 785 | { |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 786 | struct ore_io_state *ios; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 787 | struct exofs_trunc_attr { |
| 788 | struct osd_attr attr; |
| 789 | __be64 newsize; |
| 790 | } *size_attrs; |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 791 | struct _trunc_info ti; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 792 | int i, ret; |
| 793 | |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 794 | ret = ore_get_io_state(layout, oc, &ios); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 795 | if (unlikely(ret)) |
| 796 | return ret; |
| 797 | |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 798 | _calc_trunk_info(ios->layout, size, &ti); |
| 799 | |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 800 | size_attrs = kcalloc(ios->oc->numdevs, sizeof(*size_attrs), |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 801 | GFP_KERNEL); |
| 802 | if (unlikely(!size_attrs)) { |
| 803 | ret = -ENOMEM; |
| 804 | goto out; |
| 805 | } |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 806 | |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 807 | ios->numdevs = ios->oc->numdevs; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 808 | |
Boaz Harrosh | b916c5c | 2011-09-28 11:55:51 +0300 | [diff] [blame] | 809 | for (i = 0; i < ios->numdevs; ++i) { |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 810 | struct exofs_trunc_attr *size_attr = &size_attrs[i]; |
| 811 | u64 obj_size; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 812 | |
Boaz Harrosh | 16f75bb | 2011-08-03 20:44:16 -0700 | [diff] [blame] | 813 | if (i < ti.first_group_dev) |
| 814 | obj_size = ti.prev_group_obj_off; |
| 815 | else if (i >= ti.nex_group_dev) |
| 816 | obj_size = ti.next_group_obj_off; |
| 817 | else if (i < ti.si.dev) /* dev within this group */ |
| 818 | obj_size = ti.si.obj_offset + |
| 819 | ios->layout->stripe_unit - ti.si.unit_off; |
| 820 | else if (i == ti.si.dev) |
| 821 | obj_size = ti.si.obj_offset; |
| 822 | else /* i > ti.dev */ |
| 823 | obj_size = ti.si.obj_offset - ti.si.unit_off; |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 824 | |
| 825 | size_attr->newsize = cpu_to_be64(obj_size); |
| 826 | size_attr->attr = g_attr_logical_length; |
| 827 | size_attr->attr.val_ptr = &size_attr->newsize; |
| 828 | |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 829 | ORE_DBGMSG("trunc(0x%llx) obj_offset=0x%llx dev=%d\n", |
Boaz Harrosh | 5bf696d | 2011-09-28 11:39:59 +0300 | [diff] [blame] | 830 | _LLU(oc->comps->obj.id), _LLU(obj_size), i); |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 831 | ret = _truncate_mirrors(ios, i * ios->layout->mirrors_p1, |
| 832 | &size_attr->attr); |
| 833 | if (unlikely(ret)) |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 834 | goto out; |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 835 | } |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 836 | ret = ore_io_execute(ios); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 837 | |
| 838 | out: |
Boaz Harrosh | 5d952b8 | 2010-02-01 13:35:51 +0200 | [diff] [blame] | 839 | kfree(size_attrs); |
Boaz Harrosh | 8ff660a | 2011-08-06 19:26:31 -0700 | [diff] [blame] | 840 | ore_put_io_state(ios); |
Boaz Harrosh | 06886a5 | 2009-11-08 14:54:08 +0200 | [diff] [blame] | 841 | return ret; |
| 842 | } |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 843 | EXPORT_SYMBOL(ore_truncate); |
Boaz Harrosh | 85e44df | 2011-05-16 15:26:47 +0300 | [diff] [blame] | 844 | |
| 845 | const struct osd_attr g_attr_logical_length = ATTR_DEF( |
| 846 | OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8); |
Boaz Harrosh | cf283ad | 2011-08-06 19:22:06 -0700 | [diff] [blame] | 847 | EXPORT_SYMBOL(g_attr_logical_length); |