diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-08-07 01:56:03 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-08-07 01:56:03 -0400 |
| commit | c2f340a69cabe0fb7b9f02d1a2495927db225a06 (patch) | |
| tree | dd9bc3125f833adf163c47542917ebc18b1acc56 | |
| parent | 3ddcd0569cd68f00f3beae9a7959b72918bb91f4 (diff) | |
| parent | cf283ade08c454e884394a4720f22421dd33a715 (diff) | |
Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
* 'for-linus' of git://git.open-osd.org/linux-open-osd:
ore: Make ore its own module
exofs: Rename raid engine from exofs/ios.c => ore
exofs: ios: Move to a per inode components & device-table
exofs: Move exofs specific osd operations out of ios.c
exofs: Add offset/length to exofs_get_io_state
exofs: Fix truncate for the raid-groups case
exofs: Small cleanup of exofs_fill_super
exofs: BUG: Avoid sbi realloc
exofs: Remove pnfs-osd private definitions
nfs_xdr: Move nfs4_string definition out of #ifdef CONFIG_NFS_V4
| -rw-r--r-- | fs/exofs/Kbuild | 5 | ||||
| -rw-r--r-- | fs/exofs/Kconfig | 4 | ||||
| -rw-r--r-- | fs/exofs/exofs.h | 159 | ||||
| -rw-r--r-- | fs/exofs/inode.c | 152 | ||||
| -rw-r--r-- | fs/exofs/ore.c (renamed from fs/exofs/ios.c) | 370 | ||||
| -rw-r--r-- | fs/exofs/pnfs.h | 45 | ||||
| -rw-r--r-- | fs/exofs/super.c | 251 | ||||
| -rw-r--r-- | include/linux/nfs_xdr.h | 10 | ||||
| -rw-r--r-- | include/scsi/osd_ore.h | 125 |
9 files changed, 617 insertions, 504 deletions
diff --git a/fs/exofs/Kbuild b/fs/exofs/Kbuild index 2d0f757fda3e..c5a5855a6c44 100644 --- a/fs/exofs/Kbuild +++ b/fs/exofs/Kbuild | |||
| @@ -12,5 +12,8 @@ | |||
| 12 | # Kbuild - Gets included from the Kernels Makefile and build system | 12 | # Kbuild - Gets included from the Kernels Makefile and build system |
| 13 | # | 13 | # |
| 14 | 14 | ||
| 15 | exofs-y := ios.o inode.o file.o symlink.o namei.o dir.o super.o | 15 | # ore module library |
| 16 | obj-$(CONFIG_ORE) += ore.o | ||
| 17 | |||
| 18 | exofs-y := inode.o file.o symlink.o namei.o dir.o super.o | ||
| 16 | obj-$(CONFIG_EXOFS_FS) += exofs.o | 19 | obj-$(CONFIG_EXOFS_FS) += exofs.o |
diff --git a/fs/exofs/Kconfig b/fs/exofs/Kconfig index 86194b2f799d..70bae4149291 100644 --- a/fs/exofs/Kconfig +++ b/fs/exofs/Kconfig | |||
| @@ -1,6 +1,10 @@ | |||
| 1 | config ORE | ||
| 2 | tristate | ||
| 3 | |||
| 1 | config EXOFS_FS | 4 | config EXOFS_FS |
| 2 | tristate "exofs: OSD based file system support" | 5 | tristate "exofs: OSD based file system support" |
| 3 | depends on SCSI_OSD_ULD | 6 | depends on SCSI_OSD_ULD |
| 7 | select ORE | ||
| 4 | help | 8 | help |
| 5 | EXOFS is a file system that uses an OSD storage device, | 9 | EXOFS is a file system that uses an OSD storage device, |
| 6 | as its backing storage. | 10 | as its backing storage. |
diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h index c965806c2821..f4e442ec7445 100644 --- a/fs/exofs/exofs.h +++ b/fs/exofs/exofs.h | |||
| @@ -36,12 +36,9 @@ | |||
| 36 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
| 37 | #include <linux/time.h> | 37 | #include <linux/time.h> |
| 38 | #include <linux/backing-dev.h> | 38 | #include <linux/backing-dev.h> |
| 39 | #include "common.h" | 39 | #include <scsi/osd_ore.h> |
| 40 | 40 | ||
| 41 | /* FIXME: Remove once pnfs hits mainline | 41 | #include "common.h" |
| 42 | * #include <linux/exportfs/pnfs_osd_xdr.h> | ||
| 43 | */ | ||
| 44 | #include "pnfs.h" | ||
| 45 | 42 | ||
| 46 | #define EXOFS_ERR(fmt, a...) printk(KERN_ERR "exofs: " fmt, ##a) | 43 | #define EXOFS_ERR(fmt, a...) printk(KERN_ERR "exofs: " fmt, ##a) |
| 47 | 44 | ||
| @@ -56,27 +53,11 @@ | |||
| 56 | /* u64 has problems with printk this will cast it to unsigned long long */ | 53 | /* u64 has problems with printk this will cast it to unsigned long long */ |
| 57 | #define _LLU(x) (unsigned long long)(x) | 54 | #define _LLU(x) (unsigned long long)(x) |
| 58 | 55 | ||
| 59 | struct exofs_layout { | ||
| 60 | osd_id s_pid; /* partition ID of file system*/ | ||
| 61 | |||
| 62 | /* Our way of looking at the data_map */ | ||
| 63 | unsigned stripe_unit; | ||
| 64 | unsigned mirrors_p1; | ||
| 65 | |||
| 66 | unsigned group_width; | ||
| 67 | u64 group_depth; | ||
| 68 | unsigned group_count; | ||
| 69 | |||
| 70 | enum exofs_inode_layout_gen_functions lay_func; | ||
| 71 | |||
| 72 | unsigned s_numdevs; /* Num of devices in array */ | ||
| 73 | struct osd_dev *s_ods[0]; /* Variable length */ | ||
| 74 | }; | ||
| 75 | |||
| 76 | /* | 56 | /* |
| 77 | * our extension to the in-memory superblock | 57 | * our extension to the in-memory superblock |
| 78 | */ | 58 | */ |
| 79 | struct exofs_sb_info { | 59 | struct exofs_sb_info { |
| 60 | struct backing_dev_info bdi; /* register our bdi with VFS */ | ||
| 80 | struct exofs_sb_stats s_ess; /* Written often, pre-allocate*/ | 61 | struct exofs_sb_stats s_ess; /* Written often, pre-allocate*/ |
| 81 | int s_timeout; /* timeout for OSD operations */ | 62 | int s_timeout; /* timeout for OSD operations */ |
| 82 | uint64_t s_nextid; /* highest object ID used */ | 63 | uint64_t s_nextid; /* highest object ID used */ |
| @@ -84,16 +65,13 @@ struct exofs_sb_info { | |||
| 84 | spinlock_t s_next_gen_lock; /* spinlock for gen # update */ | 65 | spinlock_t s_next_gen_lock; /* spinlock for gen # update */ |
| 85 | u32 s_next_generation; /* next gen # to use */ | 66 | u32 s_next_generation; /* next gen # to use */ |
| 86 | atomic_t s_curr_pending; /* number of pending commands */ | 67 | atomic_t s_curr_pending; /* number of pending commands */ |
| 87 | uint8_t s_cred[OSD_CAP_LEN]; /* credential for the fscb */ | ||
| 88 | struct backing_dev_info bdi; /* register our bdi with VFS */ | ||
| 89 | 68 | ||
| 90 | struct pnfs_osd_data_map data_map; /* Default raid to use | 69 | struct pnfs_osd_data_map data_map; /* Default raid to use |
| 91 | * FIXME: Needed ? | 70 | * FIXME: Needed ? |
| 92 | */ | 71 | */ |
| 93 | /* struct exofs_layout dir_layout;*/ /* Default dir layout */ | 72 | struct ore_layout layout; /* Default files layout */ |
| 94 | struct exofs_layout layout; /* Default files layout, | 73 | struct ore_comp one_comp; /* id & cred of partition id=0*/ |
| 95 | * contains the variable osd_dev | 74 | struct ore_components comps; /* comps for the partition */ |
| 96 | * array. Keep last */ | ||
| 97 | struct osd_dev *_min_one_dev[1]; /* Place holder for one dev */ | 75 | struct osd_dev *_min_one_dev[1]; /* Place holder for one dev */ |
| 98 | }; | 76 | }; |
| 99 | 77 | ||
| @@ -107,7 +85,8 @@ struct exofs_i_info { | |||
| 107 | uint32_t i_data[EXOFS_IDATA];/*short symlink names and device #s*/ | 85 | uint32_t i_data[EXOFS_IDATA];/*short symlink names and device #s*/ |
| 108 | uint32_t i_dir_start_lookup; /* which page to start lookup */ | 86 | uint32_t i_dir_start_lookup; /* which page to start lookup */ |
| 109 | uint64_t i_commit_size; /* the object's written length */ | 87 | uint64_t i_commit_size; /* the object's written length */ |
| 110 | uint8_t i_cred[OSD_CAP_LEN];/* all-powerful credential */ | 88 | struct ore_comp one_comp; /* same component for all devices */ |
| 89 | struct ore_components comps; /* inode view of the device table */ | ||
| 111 | }; | 90 | }; |
| 112 | 91 | ||
| 113 | static inline osd_id exofs_oi_objno(struct exofs_i_info *oi) | 92 | static inline osd_id exofs_oi_objno(struct exofs_i_info *oi) |
| @@ -115,52 +94,6 @@ static inline osd_id exofs_oi_objno(struct exofs_i_info *oi) | |||
| 115 | return oi->vfs_inode.i_ino + EXOFS_OBJ_OFF; | 94 | return oi->vfs_inode.i_ino + EXOFS_OBJ_OFF; |
| 116 | } | 95 | } |
| 117 | 96 | ||
| 118 | struct exofs_io_state; | ||
| 119 | typedef void (*exofs_io_done_fn)(struct exofs_io_state *or, void *private); | ||
| 120 | |||
| 121 | struct exofs_io_state { | ||
| 122 | struct kref kref; | ||
| 123 | |||
| 124 | void *private; | ||
| 125 | exofs_io_done_fn done; | ||
| 126 | |||
| 127 | struct exofs_layout *layout; | ||
| 128 | struct osd_obj_id obj; | ||
| 129 | u8 *cred; | ||
| 130 | |||
| 131 | /* Global read/write IO*/ | ||
| 132 | loff_t offset; | ||
| 133 | unsigned long length; | ||
| 134 | void *kern_buff; | ||
| 135 | |||
| 136 | struct page **pages; | ||
| 137 | unsigned nr_pages; | ||
| 138 | unsigned pgbase; | ||
| 139 | unsigned pages_consumed; | ||
| 140 | |||
| 141 | /* Attributes */ | ||
| 142 | unsigned in_attr_len; | ||
| 143 | struct osd_attr *in_attr; | ||
| 144 | unsigned out_attr_len; | ||
| 145 | struct osd_attr *out_attr; | ||
| 146 | |||
| 147 | /* Variable array of size numdevs */ | ||
| 148 | unsigned numdevs; | ||
| 149 | struct exofs_per_dev_state { | ||
| 150 | struct osd_request *or; | ||
| 151 | struct bio *bio; | ||
| 152 | loff_t offset; | ||
| 153 | unsigned length; | ||
| 154 | unsigned dev; | ||
| 155 | } per_dev[]; | ||
| 156 | }; | ||
| 157 | |||
| 158 | static inline unsigned exofs_io_state_size(unsigned numdevs) | ||
| 159 | { | ||
| 160 | return sizeof(struct exofs_io_state) + | ||
| 161 | sizeof(struct exofs_per_dev_state) * numdevs; | ||
| 162 | } | ||
| 163 | |||
| 164 | /* | 97 | /* |
| 165 | * our inode flags | 98 | * our inode flags |
| 166 | */ | 99 | */ |
| @@ -205,12 +138,6 @@ static inline struct exofs_i_info *exofs_i(struct inode *inode) | |||
| 205 | } | 138 | } |
| 206 | 139 | ||
| 207 | /* | 140 | /* |
| 208 | * Given a layout, object_number and stripe_index return the associated global | ||
| 209 | * dev_index | ||
| 210 | */ | ||
| 211 | unsigned exofs_layout_od_id(struct exofs_layout *layout, | ||
| 212 | osd_id obj_no, unsigned layout_index); | ||
| 213 | /* | ||
| 214 | * Maximum count of links to a file | 141 | * Maximum count of links to a file |
| 215 | */ | 142 | */ |
| 216 | #define EXOFS_LINK_MAX 32000 | 143 | #define EXOFS_LINK_MAX 32000 |
| @@ -219,44 +146,8 @@ unsigned exofs_layout_od_id(struct exofs_layout *layout, | |||
| 219 | * function declarations * | 146 | * function declarations * |
| 220 | *************************/ | 147 | *************************/ |
| 221 | 148 | ||
| 222 | /* ios.c */ | ||
| 223 | void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], | ||
| 224 | const struct osd_obj_id *obj); | ||
| 225 | int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj, | ||
| 226 | u64 offset, void *p, unsigned length); | ||
| 227 | |||
| 228 | int exofs_get_io_state(struct exofs_layout *layout, | ||
| 229 | struct exofs_io_state **ios); | ||
| 230 | void exofs_put_io_state(struct exofs_io_state *ios); | ||
| 231 | |||
| 232 | int exofs_check_io(struct exofs_io_state *ios, u64 *resid); | ||
| 233 | |||
| 234 | int exofs_sbi_create(struct exofs_io_state *ios); | ||
| 235 | int exofs_sbi_remove(struct exofs_io_state *ios); | ||
| 236 | int exofs_sbi_write(struct exofs_io_state *ios); | ||
| 237 | int exofs_sbi_read(struct exofs_io_state *ios); | ||
| 238 | |||
| 239 | int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr); | ||
| 240 | |||
| 241 | int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len); | ||
| 242 | static inline int exofs_oi_write(struct exofs_i_info *oi, | ||
| 243 | struct exofs_io_state *ios) | ||
| 244 | { | ||
| 245 | ios->obj.id = exofs_oi_objno(oi); | ||
| 246 | ios->cred = oi->i_cred; | ||
| 247 | return exofs_sbi_write(ios); | ||
| 248 | } | ||
| 249 | |||
| 250 | static inline int exofs_oi_read(struct exofs_i_info *oi, | ||
| 251 | struct exofs_io_state *ios) | ||
| 252 | { | ||
| 253 | ios->obj.id = exofs_oi_objno(oi); | ||
| 254 | ios->cred = oi->i_cred; | ||
| 255 | return exofs_sbi_read(ios); | ||
| 256 | } | ||
| 257 | |||
| 258 | /* inode.c */ | 149 | /* inode.c */ |
| 259 | unsigned exofs_max_io_pages(struct exofs_layout *layout, | 150 | unsigned exofs_max_io_pages(struct ore_layout *layout, |
| 260 | unsigned expected_pages); | 151 | unsigned expected_pages); |
| 261 | int exofs_setattr(struct dentry *, struct iattr *); | 152 | int exofs_setattr(struct dentry *, struct iattr *); |
| 262 | int exofs_write_begin(struct file *file, struct address_space *mapping, | 153 | int exofs_write_begin(struct file *file, struct address_space *mapping, |
| @@ -281,6 +172,8 @@ int exofs_set_link(struct inode *, struct exofs_dir_entry *, struct page *, | |||
| 281 | struct inode *); | 172 | struct inode *); |
| 282 | 173 | ||
| 283 | /* super.c */ | 174 | /* super.c */ |
| 175 | void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], | ||
| 176 | const struct osd_obj_id *obj); | ||
| 284 | int exofs_sbi_write_stats(struct exofs_sb_info *sbi); | 177 | int exofs_sbi_write_stats(struct exofs_sb_info *sbi); |
| 285 | 178 | ||
| 286 | /********************* | 179 | /********************* |
| @@ -295,7 +188,6 @@ extern const struct file_operations exofs_file_operations; | |||
| 295 | 188 | ||
| 296 | /* inode.c */ | 189 | /* inode.c */ |
| 297 | extern const struct address_space_operations exofs_aops; | 190 | extern const struct address_space_operations exofs_aops; |
| 298 | extern const struct osd_attr g_attr_logical_length; | ||
| 299 | 191 | ||
| 300 | /* namei.c */ | 192 | /* namei.c */ |
| 301 | extern const struct inode_operations exofs_dir_inode_operations; | 193 | extern const struct inode_operations exofs_dir_inode_operations; |
| @@ -305,4 +197,33 @@ extern const struct inode_operations exofs_special_inode_operations; | |||
| 305 | extern const struct inode_operations exofs_symlink_inode_operations; | 197 | extern const struct inode_operations exofs_symlink_inode_operations; |
| 306 | extern const struct inode_operations exofs_fast_symlink_inode_operations; | 198 | extern const struct inode_operations exofs_fast_symlink_inode_operations; |
| 307 | 199 | ||
| 200 | /* exofs_init_comps will initialize an ore_components device array | ||
| 201 | * pointing to a single ore_comp struct, and a round-robin view | ||
| 202 | * of the device table. | ||
| 203 | * The first device of each inode is the [inode->ino % num_devices] | ||
| 204 | * and the rest of the devices sequentially following where the | ||
| 205 | * first device is after the last device. | ||
| 206 | * It is assumed that the global device array at @sbi is twice | ||
| 207 | * bigger and that the device table repeats twice. | ||
| 208 | * See: exofs_read_lookup_dev_table() | ||
| 209 | */ | ||
| 210 | static inline void exofs_init_comps(struct ore_components *comps, | ||
| 211 | struct ore_comp *one_comp, | ||
| 212 | struct exofs_sb_info *sbi, osd_id oid) | ||
| 213 | { | ||
| 214 | unsigned dev_mod = (unsigned)oid, first_dev; | ||
| 215 | |||
| 216 | one_comp->obj.partition = sbi->one_comp.obj.partition; | ||
| 217 | one_comp->obj.id = oid; | ||
| 218 | exofs_make_credential(one_comp->cred, &one_comp->obj); | ||
| 219 | |||
| 220 | comps->numdevs = sbi->comps.numdevs; | ||
| 221 | comps->single_comp = EC_SINGLE_COMP; | ||
| 222 | comps->comps = one_comp; | ||
| 223 | |||
| 224 | /* Round robin device view of the table */ | ||
| 225 | first_dev = (dev_mod * sbi->layout.mirrors_p1) % sbi->comps.numdevs; | ||
| 226 | comps->ods = sbi->comps.ods + first_dev; | ||
| 227 | } | ||
| 228 | |||
| 308 | #endif | 229 | #endif |
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index 8472c098445d..f39a38fc2349 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c | |||
| @@ -43,7 +43,7 @@ enum { BIO_MAX_PAGES_KMALLOC = | |||
| 43 | PAGE_SIZE / sizeof(struct page *), | 43 | PAGE_SIZE / sizeof(struct page *), |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | unsigned exofs_max_io_pages(struct exofs_layout *layout, | 46 | unsigned exofs_max_io_pages(struct ore_layout *layout, |
| 47 | unsigned expected_pages) | 47 | unsigned expected_pages) |
| 48 | { | 48 | { |
| 49 | unsigned pages = min_t(unsigned, expected_pages, MAX_PAGES_KMALLOC); | 49 | unsigned pages = min_t(unsigned, expected_pages, MAX_PAGES_KMALLOC); |
| @@ -58,7 +58,7 @@ struct page_collect { | |||
| 58 | struct exofs_sb_info *sbi; | 58 | struct exofs_sb_info *sbi; |
| 59 | struct inode *inode; | 59 | struct inode *inode; |
| 60 | unsigned expected_pages; | 60 | unsigned expected_pages; |
| 61 | struct exofs_io_state *ios; | 61 | struct ore_io_state *ios; |
| 62 | 62 | ||
| 63 | struct page **pages; | 63 | struct page **pages; |
| 64 | unsigned alloc_pages; | 64 | unsigned alloc_pages; |
| @@ -110,13 +110,6 @@ static int pcol_try_alloc(struct page_collect *pcol) | |||
| 110 | { | 110 | { |
| 111 | unsigned pages; | 111 | unsigned pages; |
| 112 | 112 | ||
| 113 | if (!pcol->ios) { /* First time allocate io_state */ | ||
| 114 | int ret = exofs_get_io_state(&pcol->sbi->layout, &pcol->ios); | ||
| 115 | |||
| 116 | if (ret) | ||
| 117 | return ret; | ||
| 118 | } | ||
| 119 | |||
| 120 | /* TODO: easily support bio chaining */ | 113 | /* TODO: easily support bio chaining */ |
| 121 | pages = exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages); | 114 | pages = exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages); |
| 122 | 115 | ||
| @@ -140,7 +133,7 @@ static void pcol_free(struct page_collect *pcol) | |||
| 140 | pcol->pages = NULL; | 133 | pcol->pages = NULL; |
| 141 | 134 | ||
| 142 | if (pcol->ios) { | 135 | if (pcol->ios) { |
| 143 | exofs_put_io_state(pcol->ios); | 136 | ore_put_io_state(pcol->ios); |
| 144 | pcol->ios = NULL; | 137 | pcol->ios = NULL; |
| 145 | } | 138 | } |
| 146 | } | 139 | } |
| @@ -200,7 +193,7 @@ static int __readpages_done(struct page_collect *pcol) | |||
| 200 | u64 resid; | 193 | u64 resid; |
| 201 | u64 good_bytes; | 194 | u64 good_bytes; |
| 202 | u64 length = 0; | 195 | u64 length = 0; |
| 203 | int ret = exofs_check_io(pcol->ios, &resid); | 196 | int ret = ore_check_io(pcol->ios, &resid); |
| 204 | 197 | ||
| 205 | if (likely(!ret)) | 198 | if (likely(!ret)) |
| 206 | good_bytes = pcol->length; | 199 | good_bytes = pcol->length; |
| @@ -241,7 +234,7 @@ static int __readpages_done(struct page_collect *pcol) | |||
| 241 | } | 234 | } |
| 242 | 235 | ||
| 243 | /* callback of async reads */ | 236 | /* callback of async reads */ |
| 244 | static void readpages_done(struct exofs_io_state *ios, void *p) | 237 | static void readpages_done(struct ore_io_state *ios, void *p) |
| 245 | { | 238 | { |
| 246 | struct page_collect *pcol = p; | 239 | struct page_collect *pcol = p; |
| 247 | 240 | ||
| @@ -269,20 +262,28 @@ static void _unlock_pcol_pages(struct page_collect *pcol, int ret, int rw) | |||
| 269 | static int read_exec(struct page_collect *pcol) | 262 | static int read_exec(struct page_collect *pcol) |
| 270 | { | 263 | { |
| 271 | struct exofs_i_info *oi = exofs_i(pcol->inode); | 264 | struct exofs_i_info *oi = exofs_i(pcol->inode); |
| 272 | struct exofs_io_state *ios = pcol->ios; | 265 | struct ore_io_state *ios; |
| 273 | struct page_collect *pcol_copy = NULL; | 266 | struct page_collect *pcol_copy = NULL; |
| 274 | int ret; | 267 | int ret; |
| 275 | 268 | ||
| 276 | if (!pcol->pages) | 269 | if (!pcol->pages) |
| 277 | return 0; | 270 | return 0; |
| 278 | 271 | ||
| 272 | if (!pcol->ios) { | ||
| 273 | int ret = ore_get_rw_state(&pcol->sbi->layout, &oi->comps, true, | ||
| 274 | pcol->pg_first << PAGE_CACHE_SHIFT, | ||
| 275 | pcol->length, &pcol->ios); | ||
| 276 | |||
| 277 | if (ret) | ||
| 278 | return ret; | ||
| 279 | } | ||
| 280 | |||
| 281 | ios = pcol->ios; | ||
| 279 | ios->pages = pcol->pages; | 282 | ios->pages = pcol->pages; |
| 280 | ios->nr_pages = pcol->nr_pages; | 283 | ios->nr_pages = pcol->nr_pages; |
| 281 | ios->length = pcol->length; | ||
| 282 | ios->offset = pcol->pg_first << PAGE_CACHE_SHIFT; | ||
| 283 | 284 | ||
| 284 | if (pcol->read_4_write) { | 285 | if (pcol->read_4_write) { |
| 285 | exofs_oi_read(oi, pcol->ios); | 286 | ore_read(pcol->ios); |
| 286 | return __readpages_done(pcol); | 287 | return __readpages_done(pcol); |
| 287 | } | 288 | } |
| 288 | 289 | ||
| @@ -295,14 +296,14 @@ static int read_exec(struct page_collect *pcol) | |||
| 295 | *pcol_copy = *pcol; | 296 | *pcol_copy = *pcol; |
| 296 | ios->done = readpages_done; | 297 | ios->done = readpages_done; |
| 297 | ios->private = pcol_copy; | 298 | ios->private = pcol_copy; |
| 298 | ret = exofs_oi_read(oi, ios); | 299 | ret = ore_read(ios); |
| 299 | if (unlikely(ret)) | 300 | if (unlikely(ret)) |
| 300 | goto err; | 301 | goto err; |
| 301 | 302 | ||
| 302 | atomic_inc(&pcol->sbi->s_curr_pending); | 303 | atomic_inc(&pcol->sbi->s_curr_pending); |
| 303 | 304 | ||
| 304 | EXOFS_DBGMSG2("read_exec obj=0x%llx start=0x%llx length=0x%lx\n", | 305 | EXOFS_DBGMSG2("read_exec obj=0x%llx start=0x%llx length=0x%lx\n", |
| 305 | ios->obj.id, _LLU(ios->offset), pcol->length); | 306 | oi->one_comp.obj.id, _LLU(ios->offset), pcol->length); |
| 306 | 307 | ||
| 307 | /* pages ownership was passed to pcol_copy */ | 308 | /* pages ownership was passed to pcol_copy */ |
| 308 | _pcol_reset(pcol); | 309 | _pcol_reset(pcol); |
| @@ -457,14 +458,14 @@ static int exofs_readpage(struct file *file, struct page *page) | |||
| 457 | } | 458 | } |
| 458 | 459 | ||
| 459 | /* Callback for osd_write. All writes are asynchronous */ | 460 | /* Callback for osd_write. All writes are asynchronous */ |
| 460 | static void writepages_done(struct exofs_io_state *ios, void *p) | 461 | static void writepages_done(struct ore_io_state *ios, void *p) |
| 461 | { | 462 | { |
| 462 | struct page_collect *pcol = p; | 463 | struct page_collect *pcol = p; |
| 463 | int i; | 464 | int i; |
| 464 | u64 resid; | 465 | u64 resid; |
| 465 | u64 good_bytes; | 466 | u64 good_bytes; |
| 466 | u64 length = 0; | 467 | u64 length = 0; |
| 467 | int ret = exofs_check_io(ios, &resid); | 468 | int ret = ore_check_io(ios, &resid); |
| 468 | 469 | ||
| 469 | atomic_dec(&pcol->sbi->s_curr_pending); | 470 | atomic_dec(&pcol->sbi->s_curr_pending); |
| 470 | 471 | ||
| @@ -507,13 +508,21 @@ static void writepages_done(struct exofs_io_state *ios, void *p) | |||
| 507 | static int write_exec(struct page_collect *pcol) | 508 | static int write_exec(struct page_collect *pcol) |
| 508 | { | 509 | { |
| 509 | struct exofs_i_info *oi = exofs_i(pcol->inode); | 510 | struct exofs_i_info *oi = exofs_i(pcol->inode); |
| 510 | struct exofs_io_state *ios = pcol->ios; | 511 | struct ore_io_state *ios; |
| 511 | struct page_collect *pcol_copy = NULL; | 512 | struct page_collect *pcol_copy = NULL; |
| 512 | int ret; | 513 | int ret; |
| 513 | 514 | ||
| 514 | if (!pcol->pages) | 515 | if (!pcol->pages) |
| 515 | return 0; | 516 | return 0; |
| 516 | 517 | ||
| 518 | BUG_ON(pcol->ios); | ||
| 519 | ret = ore_get_rw_state(&pcol->sbi->layout, &oi->comps, false, | ||
| 520 | pcol->pg_first << PAGE_CACHE_SHIFT, | ||
| 521 | pcol->length, &pcol->ios); | ||
| 522 | |||
| 523 | if (unlikely(ret)) | ||
| 524 | goto err; | ||
| 525 | |||
| 517 | pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL); | 526 | pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL); |
| 518 | if (!pcol_copy) { | 527 | if (!pcol_copy) { |
| 519 | EXOFS_ERR("write_exec: Failed to kmalloc(pcol)\n"); | 528 | EXOFS_ERR("write_exec: Failed to kmalloc(pcol)\n"); |
| @@ -523,16 +532,15 @@ static int write_exec(struct page_collect *pcol) | |||
| 523 | 532 | ||
| 524 | *pcol_copy = *pcol; | 533 | *pcol_copy = *pcol; |
| 525 | 534 | ||
| 535 | ios = pcol->ios; | ||
| 526 | ios->pages = pcol_copy->pages; | 536 | ios->pages = pcol_copy->pages; |
| 527 | ios->nr_pages = pcol_copy->nr_pages; | 537 | ios->nr_pages = pcol_copy->nr_pages; |
| 528 | ios->offset = pcol_copy->pg_first << PAGE_CACHE_SHIFT; | ||
| 529 | ios->length = pcol_copy->length; | ||
| 530 | ios->done = writepages_done; | 538 | ios->done = writepages_done; |
| 531 | ios->private = pcol_copy; | 539 | ios->private = pcol_copy; |
| 532 | 540 | ||
| 533 | ret = exofs_oi_write(oi, ios); | 541 | ret = ore_write(ios); |
| 534 | if (unlikely(ret)) { | 542 | if (unlikely(ret)) { |
| 535 | EXOFS_ERR("write_exec: exofs_oi_write() Failed\n"); | 543 | EXOFS_ERR("write_exec: ore_write() Failed\n"); |
| 536 | goto err; | 544 | goto err; |
| 537 | } | 545 | } |
| 538 | 546 | ||
| @@ -844,17 +852,15 @@ static inline int exofs_inode_is_fast_symlink(struct inode *inode) | |||
| 844 | return S_ISLNK(inode->i_mode) && (oi->i_data[0] != 0); | 852 | return S_ISLNK(inode->i_mode) && (oi->i_data[0] != 0); |
| 845 | } | 853 | } |
| 846 | 854 | ||
| 847 | const struct osd_attr g_attr_logical_length = ATTR_DEF( | ||
| 848 | OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8); | ||
| 849 | |||
| 850 | static int _do_truncate(struct inode *inode, loff_t newsize) | 855 | static int _do_truncate(struct inode *inode, loff_t newsize) |
| 851 | { | 856 | { |
| 852 | struct exofs_i_info *oi = exofs_i(inode); | 857 | struct exofs_i_info *oi = exofs_i(inode); |
| 858 | struct exofs_sb_info *sbi = inode->i_sb->s_fs_info; | ||
| 853 | int ret; | 859 | int ret; |
| 854 | 860 | ||
| 855 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 861 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
| 856 | 862 | ||
| 857 | ret = exofs_oi_truncate(oi, (u64)newsize); | 863 | ret = ore_truncate(&sbi->layout, &oi->comps, (u64)newsize); |
| 858 | if (likely(!ret)) | 864 | if (likely(!ret)) |
| 859 | truncate_setsize(inode, newsize); | 865 | truncate_setsize(inode, newsize); |
| 860 | 866 | ||
| @@ -917,30 +923,26 @@ static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi, | |||
| 917 | [1] = g_attr_inode_file_layout, | 923 | [1] = g_attr_inode_file_layout, |
| 918 | [2] = g_attr_inode_dir_layout, | 924 | [2] = g_attr_inode_dir_layout, |
| 919 | }; | 925 | }; |
| 920 | struct exofs_io_state *ios; | 926 | struct ore_io_state *ios; |
| 921 | struct exofs_on_disk_inode_layout *layout; | 927 | struct exofs_on_disk_inode_layout *layout; |
| 922 | int ret; | 928 | int ret; |
| 923 | 929 | ||
| 924 | ret = exofs_get_io_state(&sbi->layout, &ios); | 930 | ret = ore_get_io_state(&sbi->layout, &oi->comps, &ios); |
| 925 | if (unlikely(ret)) { | 931 | if (unlikely(ret)) { |
| 926 | EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__); | 932 | EXOFS_ERR("%s: ore_get_io_state failed.\n", __func__); |
| 927 | return ret; | 933 | return ret; |
| 928 | } | 934 | } |
| 929 | 935 | ||
| 930 | ios->obj.id = exofs_oi_objno(oi); | 936 | attrs[1].len = exofs_on_disk_inode_layout_size(sbi->comps.numdevs); |
| 931 | exofs_make_credential(oi->i_cred, &ios->obj); | 937 | attrs[2].len = exofs_on_disk_inode_layout_size(sbi->comps.numdevs); |
| 932 | ios->cred = oi->i_cred; | ||
| 933 | |||
| 934 | attrs[1].len = exofs_on_disk_inode_layout_size(sbi->layout.s_numdevs); | ||
| 935 | attrs[2].len = exofs_on_disk_inode_layout_size(sbi->layout.s_numdevs); | ||
| 936 | 938 | ||
| 937 | ios->in_attr = attrs; | 939 | ios->in_attr = attrs; |
| 938 | ios->in_attr_len = ARRAY_SIZE(attrs); | 940 | ios->in_attr_len = ARRAY_SIZE(attrs); |
| 939 | 941 | ||
| 940 | ret = exofs_sbi_read(ios); | 942 | ret = ore_read(ios); |
| 941 | if (unlikely(ret)) { | 943 | if (unlikely(ret)) { |
| 942 | EXOFS_ERR("object(0x%llx) corrupted, return empty file=>%d\n", | 944 | EXOFS_ERR("object(0x%llx) corrupted, return empty file=>%d\n", |
| 943 | _LLU(ios->obj.id), ret); | 945 | _LLU(oi->one_comp.obj.id), ret); |
| 944 | memset(inode, 0, sizeof(*inode)); | 946 | memset(inode, 0, sizeof(*inode)); |
| 945 | inode->i_mode = 0040000 | (0777 & ~022); | 947 | inode->i_mode = 0040000 | (0777 & ~022); |
| 946 | /* If object is lost on target we might as well enable it's | 948 | /* If object is lost on target we might as well enable it's |
| @@ -990,7 +992,7 @@ static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi, | |||
| 990 | } | 992 | } |
| 991 | 993 | ||
| 992 | out: | 994 | out: |
| 993 | exofs_put_io_state(ios); | 995 | ore_put_io_state(ios); |
| 994 | return ret; | 996 | return ret; |
| 995 | } | 997 | } |
| 996 | 998 | ||
| @@ -1016,6 +1018,8 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino) | |||
| 1016 | return inode; | 1018 | return inode; |
| 1017 | oi = exofs_i(inode); | 1019 | oi = exofs_i(inode); |
| 1018 | __oi_init(oi); | 1020 | __oi_init(oi); |
| 1021 | exofs_init_comps(&oi->comps, &oi->one_comp, sb->s_fs_info, | ||
| 1022 | exofs_oi_objno(oi)); | ||
| 1019 | 1023 | ||
| 1020 | /* read the inode from the osd */ | 1024 | /* read the inode from the osd */ |
| 1021 | ret = exofs_get_inode(sb, oi, &fcb); | 1025 | ret = exofs_get_inode(sb, oi, &fcb); |
| @@ -1107,21 +1111,22 @@ int __exofs_wait_obj_created(struct exofs_i_info *oi) | |||
| 1107 | * set the obj_created flag so that other methods know that the object exists on | 1111 | * set the obj_created flag so that other methods know that the object exists on |
| 1108 | * the OSD. | 1112 | * the OSD. |
| 1109 | */ | 1113 | */ |
| 1110 | static void create_done(struct exofs_io_state *ios, void *p) | 1114 | static void create_done(struct ore_io_state *ios, void *p) |
| 1111 | { | 1115 | { |
| 1112 | struct inode *inode = p; | 1116 | struct inode *inode = p; |
| 1113 | struct exofs_i_info *oi = exofs_i(inode); | 1117 | struct exofs_i_info *oi = exofs_i(inode); |
| 1114 | struct exofs_sb_info *sbi = inode->i_sb->s_fs_info; | 1118 | struct exofs_sb_info *sbi = inode->i_sb->s_fs_info; |
| 1115 | int ret; | 1119 | int ret; |
| 1116 | 1120 | ||
| 1117 | ret = exofs_check_io(ios, NULL); | 1121 | ret = ore_check_io(ios, NULL); |
| 1118 | exofs_put_io_state(ios); | 1122 | ore_put_io_state(ios); |
| 1119 | 1123 | ||
| 1120 | atomic_dec(&sbi->s_curr_pending); | 1124 | atomic_dec(&sbi->s_curr_pending); |
| 1121 | 1125 | ||
| 1122 | if (unlikely(ret)) { | 1126 | if (unlikely(ret)) { |
| 1123 | EXOFS_ERR("object=0x%llx creation failed in pid=0x%llx", | 1127 | EXOFS_ERR("object=0x%llx creation failed in pid=0x%llx", |
| 1124 | _LLU(exofs_oi_objno(oi)), _LLU(sbi->layout.s_pid)); | 1128 | _LLU(exofs_oi_objno(oi)), |
| 1129 | _LLU(oi->one_comp.obj.partition)); | ||
| 1125 | /*TODO: When FS is corrupted creation can fail, object already | 1130 | /*TODO: When FS is corrupted creation can fail, object already |
| 1126 | * exist. Get rid of this asynchronous creation, if exist | 1131 | * exist. Get rid of this asynchronous creation, if exist |
| 1127 | * increment the obj counter and try the next object. Until we | 1132 | * increment the obj counter and try the next object. Until we |
| @@ -1140,14 +1145,13 @@ static void create_done(struct exofs_io_state *ios, void *p) | |||
| 1140 | */ | 1145 | */ |
| 1141 | struct inode *exofs_new_inode(struct inode *dir, int mode) | 1146 | struct inode *exofs_new_inode(struct inode *dir, int mode) |
| 1142 | { | 1147 | { |
| 1143 | struct super_block *sb; | 1148 | struct super_block *sb = dir->i_sb; |
| 1149 | struct exofs_sb_info *sbi = sb->s_fs_info; | ||
| 1144 | struct inode *inode; | 1150 | struct inode *inode; |
| 1145 | struct exofs_i_info *oi; | 1151 | struct exofs_i_info *oi; |
| 1146 | struct exofs_sb_info *sbi; | 1152 | struct ore_io_state *ios; |
| 1147 | struct exofs_io_state *ios; | ||
| 1148 | int ret; | 1153 | int ret; |
| 1149 | 1154 | ||
| 1150 | sb = dir->i_sb; | ||
| 1151 | inode = new_inode(sb); | 1155 | inode = new_inode(sb); |
| 1152 | if (!inode) | 1156 | if (!inode) |
| 1153 | return ERR_PTR(-ENOMEM); | 1157 | return ERR_PTR(-ENOMEM); |
| @@ -1157,8 +1161,6 @@ struct inode *exofs_new_inode(struct inode *dir, int mode) | |||
| 1157 | 1161 | ||
| 1158 | set_obj_2bcreated(oi); | 1162 | set_obj_2bcreated(oi); |
| 1159 | 1163 | ||
| 1160 | sbi = sb->s_fs_info; | ||
| 1161 | |||
| 1162 | inode->i_mapping->backing_dev_info = sb->s_bdi; | 1164 | inode->i_mapping->backing_dev_info = sb->s_bdi; |
| 1163 | inode_init_owner(inode, dir, mode); | 1165 | inode_init_owner(inode, dir, mode); |
| 1164 | inode->i_ino = sbi->s_nextid++; | 1166 | inode->i_ino = sbi->s_nextid++; |
| @@ -1170,25 +1172,24 @@ struct inode *exofs_new_inode(struct inode *dir, int mode) | |||
| 1170 | spin_unlock(&sbi->s_next_gen_lock); | 1172 | spin_unlock(&sbi->s_next_gen_lock); |
| 1171 | insert_inode_hash(inode); | 1173 | insert_inode_hash(inode); |
| 1172 | 1174 | ||
| 1175 | exofs_init_comps(&oi->comps, &oi->one_comp, sb->s_fs_info, | ||
| 1176 | exofs_oi_objno(oi)); | ||
| 1173 | exofs_sbi_write_stats(sbi); /* Make sure new sbi->s_nextid is on disk */ | 1177 | exofs_sbi_write_stats(sbi); /* Make sure new sbi->s_nextid is on disk */ |
| 1174 | 1178 | ||
| 1175 | mark_inode_dirty(inode); | 1179 | mark_inode_dirty(inode); |
| 1176 | 1180 | ||
| 1177 | ret = exofs_get_io_state(&sbi->layout, &ios); | 1181 | ret = ore_get_io_state(&sbi->layout, &oi->comps, &ios); |
| 1178 | if (unlikely(ret)) { | 1182 | if (unlikely(ret)) { |
| 1179 | EXOFS_ERR("exofs_new_inode: exofs_get_io_state failed\n"); | 1183 | EXOFS_ERR("exofs_new_inode: ore_get_io_state failed\n"); |
| 1180 | return ERR_PTR(ret); | 1184 | return ERR_PTR(ret); |
| 1181 | } | 1185 | } |
| 1182 | 1186 | ||
| 1183 | ios->obj.id = exofs_oi_objno(oi); | ||
| 1184 | exofs_make_credential(oi->i_cred, &ios->obj); | ||
| 1185 | |||
| 1186 | ios->done = create_done; | 1187 | ios->done = create_done; |
| 1187 | ios->private = inode; | 1188 | ios->private = inode; |
| 1188 | ios->cred = oi->i_cred; | 1189 | |
| 1189 | ret = exofs_sbi_create(ios); | 1190 | ret = ore_create(ios); |
| 1190 | if (ret) { | 1191 | if (ret) { |
| 1191 | exofs_put_io_state(ios); | 1192 | ore_put_io_state(ios); |
| 1192 | return ERR_PTR(ret); | 1193 | return ERR_PTR(ret); |
| 1193 | } | 1194 | } |
| 1194 | atomic_inc(&sbi->s_curr_pending); | 1195 | atomic_inc(&sbi->s_curr_pending); |
| @@ -1207,11 +1208,11 @@ struct updatei_args { | |||
| 1207 | /* | 1208 | /* |
| 1208 | * Callback function from exofs_update_inode(). | 1209 | * Callback function from exofs_update_inode(). |
| 1209 | */ | 1210 | */ |
| 1210 | static void updatei_done(struct exofs_io_state *ios, void *p) | 1211 | static void updatei_done(struct ore_io_state *ios, void *p) |
| 1211 | { | 1212 | { |
| 1212 | struct updatei_args *args = p; | 1213 | struct updatei_args *args = p; |
| 1213 | 1214 | ||
| 1214 | exofs_put_io_state(ios); | 1215 | ore_put_io_state(ios); |
| 1215 | 1216 | ||
| 1216 | atomic_dec(&args->sbi->s_curr_pending); | 1217 | atomic_dec(&args->sbi->s_curr_pending); |
| 1217 | 1218 | ||
| @@ -1227,7 +1228,7 @@ static int exofs_update_inode(struct inode *inode, int do_sync) | |||
| 1227 | struct exofs_i_info *oi = exofs_i(inode); | 1228 | struct exofs_i_info *oi = exofs_i(inode); |
| 1228 | struct super_block *sb = inode->i_sb; | 1229 | struct super_block *sb = inode->i_sb; |
| 1229 | struct exofs_sb_info *sbi = sb->s_fs_info; | 1230 | struct exofs_sb_info *sbi = sb->s_fs_info; |
| 1230 | struct exofs_io_state *ios; | 1231 | struct ore_io_state *ios; |
| 1231 | struct osd_attr attr; | 1232 | struct osd_attr attr; |
| 1232 | struct exofs_fcb *fcb; | 1233 | struct exofs_fcb *fcb; |
| 1233 | struct updatei_args *args; | 1234 | struct updatei_args *args; |
| @@ -1266,9 +1267,9 @@ static int exofs_update_inode(struct inode *inode, int do_sync) | |||
| 1266 | } else | 1267 | } else |
| 1267 | memcpy(fcb->i_data, oi->i_data, sizeof(fcb->i_data)); | 1268 | memcpy(fcb->i_data, oi->i_data, sizeof(fcb->i_data)); |
| 1268 | 1269 | ||
| 1269 | ret = exofs_get_io_state(&sbi->layout, &ios); | 1270 | ret = ore_get_io_state(&sbi->layout, &oi->comps, &ios); |
| 1270 | if (unlikely(ret)) { | 1271 | if (unlikely(ret)) { |
| 1271 | EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__); | 1272 | EXOFS_ERR("%s: ore_get_io_state failed.\n", __func__); |
| 1272 | goto free_args; | 1273 | goto free_args; |
| 1273 | } | 1274 | } |
| 1274 | 1275 | ||
| @@ -1285,13 +1286,13 @@ static int exofs_update_inode(struct inode *inode, int do_sync) | |||
| 1285 | ios->private = args; | 1286 | ios->private = args; |
| 1286 | } | 1287 | } |
| 1287 | 1288 | ||
| 1288 | ret = exofs_oi_write(oi, ios); | 1289 | ret = ore_write(ios); |
| 1289 | if (!do_sync && !ret) { | 1290 | if (!do_sync && !ret) { |
| 1290 | atomic_inc(&sbi->s_curr_pending); | 1291 | atomic_inc(&sbi->s_curr_pending); |
| 1291 | goto out; /* deallocation in updatei_done */ | 1292 | goto out; /* deallocation in updatei_done */ |
| 1292 | } | 1293 | } |
| 1293 | 1294 | ||
| 1294 | exofs_put_io_state(ios); | 1295 | ore_put_io_state(ios); |
| 1295 | free_args: | 1296 | free_args: |
| 1296 | kfree(args); | 1297 | kfree(args); |
| 1297 | out: | 1298 | out: |
| @@ -1310,11 +1311,11 @@ int exofs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
| 1310 | * Callback function from exofs_delete_inode() - don't have much cleaning up to | 1311 | * Callback function from exofs_delete_inode() - don't have much cleaning up to |
| 1311 | * do. | 1312 | * do. |
| 1312 | */ | 1313 | */ |
| 1313 | static void delete_done(struct exofs_io_state *ios, void *p) | 1314 | static void delete_done(struct ore_io_state *ios, void *p) |
| 1314 | { | 1315 | { |
| 1315 | struct exofs_sb_info *sbi = p; | 1316 | struct exofs_sb_info *sbi = p; |
| 1316 | 1317 | ||
| 1317 | exofs_put_io_state(ios); | 1318 | ore_put_io_state(ios); |
| 1318 | 1319 | ||
| 1319 | atomic_dec(&sbi->s_curr_pending); | 1320 | atomic_dec(&sbi->s_curr_pending); |
| 1320 | } | 1321 | } |
| @@ -1329,7 +1330,7 @@ void exofs_evict_inode(struct inode *inode) | |||
| 1329 | struct exofs_i_info *oi = exofs_i(inode); | 1330 | struct exofs_i_info *oi = exofs_i(inode); |
| 1330 | struct super_block *sb = inode->i_sb; | 1331 | struct super_block *sb = inode->i_sb; |
| 1331 | struct exofs_sb_info *sbi = sb->s_fs_info; | 1332 | struct exofs_sb_info *sbi = sb->s_fs_info; |
| 1332 | struct exofs_io_state *ios; | 1333 | struct ore_io_state *ios; |
| 1333 | int ret; | 1334 | int ret; |
| 1334 | 1335 | ||
| 1335 | truncate_inode_pages(&inode->i_data, 0); | 1336 | truncate_inode_pages(&inode->i_data, 0); |
| @@ -1349,20 +1350,19 @@ void exofs_evict_inode(struct inode *inode) | |||
| 1349 | /* ignore the error, attempt a remove anyway */ | 1350 | /* ignore the error, attempt a remove anyway */ |
| 1350 | 1351 | ||
| 1351 | /* Now Remove the OSD objects */ | 1352 | /* Now Remove the OSD objects */ |
| 1352 | ret = exofs_get_io_state(&sbi->layout, &ios); | 1353 | ret = ore_get_io_state(&sbi->layout, &oi->comps, &ios); |
| 1353 | if (unlikely(ret)) { | 1354 | if (unlikely(ret)) { |
| 1354 | EXOFS_ERR("%s: exofs_get_io_state failed\n", __func__); | 1355 | EXOFS_ERR("%s: ore_get_io_state failed\n", __func__); |
| 1355 | return; | 1356 | return; |
| 1356 | } | 1357 | } |
| 1357 | 1358 | ||
| 1358 | ios->obj.id = exofs_oi_objno(oi); | ||
| 1359 | ios->done = delete_done; | 1359 | ios->done = delete_done; |
| 1360 | ios->private = sbi; | 1360 | ios->private = sbi; |
| 1361 | ios->cred = oi->i_cred; | 1361 | |
| 1362 | ret = exofs_sbi_remove(ios); | 1362 | ret = ore_remove(ios); |
| 1363 | if (ret) { | 1363 | if (ret) { |
| 1364 | EXOFS_ERR("%s: exofs_sbi_remove failed\n", __func__); | 1364 | EXOFS_ERR("%s: ore_remove failed\n", __func__); |
| 1365 | exofs_put_io_state(ios); | 1365 | ore_put_io_state(ios); |
| 1366 | return; | 1366 | return; |
| 1367 | } | 1367 | } |
| 1368 | atomic_inc(&sbi->s_curr_pending); | 1368 | atomic_inc(&sbi->s_curr_pending); |
diff --git a/fs/exofs/ios.c b/fs/exofs/ore.c index f74a2ec027a6..25305af88198 100644 --- a/fs/exofs/ios.c +++ b/fs/exofs/ore.c | |||
| @@ -23,81 +23,87 @@ | |||
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| 26 | #include <scsi/scsi_device.h> | ||
| 27 | #include <asm/div64.h> | 26 | #include <asm/div64.h> |
| 28 | 27 | ||
| 29 | #include "exofs.h" | 28 | #include <scsi/osd_ore.h> |
| 30 | 29 | ||
| 31 | #define EXOFS_DBGMSG2(M...) do {} while (0) | 30 | #define ORE_ERR(fmt, a...) printk(KERN_ERR "ore: " fmt, ##a) |
| 32 | /* #define EXOFS_DBGMSG2 EXOFS_DBGMSG */ | ||
| 33 | 31 | ||
| 34 | void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], const struct osd_obj_id *obj) | 32 | #ifdef CONFIG_EXOFS_DEBUG |
| 35 | { | 33 | #define ORE_DBGMSG(fmt, a...) \ |
| 36 | osd_sec_init_nosec_doall_caps(cred_a, obj, false, true); | 34 | printk(KERN_NOTICE "ore @%s:%d: " fmt, __func__, __LINE__, ##a) |
| 37 | } | 35 | #else |
| 36 | #define ORE_DBGMSG(fmt, a...) \ | ||
| 37 | do { if (0) printk(fmt, ##a); } while (0) | ||
| 38 | #endif | ||
| 38 | 39 | ||
| 39 | int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj, | 40 | /* u64 has problems with printk this will cast it to unsigned long long */ |
| 40 | u64 offset, void *p, unsigned length) | 41 | #define _LLU(x) (unsigned long long)(x) |
| 41 | { | ||
| 42 | struct osd_request *or = osd_start_request(od, GFP_KERNEL); | ||
| 43 | /* struct osd_sense_info osi = {.key = 0};*/ | ||
| 44 | int ret; | ||
| 45 | 42 | ||
| 46 | if (unlikely(!or)) { | 43 | #define ORE_DBGMSG2(M...) do {} while (0) |
| 47 | EXOFS_DBGMSG("%s: osd_start_request failed.\n", __func__); | 44 | /* #define ORE_DBGMSG2 ORE_DBGMSG */ |
| 48 | return -ENOMEM; | ||
| 49 | } | ||
| 50 | ret = osd_req_read_kern(or, obj, offset, p, length); | ||
| 51 | if (unlikely(ret)) { | ||
| 52 | EXOFS_DBGMSG("%s: osd_req_read_kern failed.\n", __func__); | ||
| 53 | goto out; | ||
| 54 | } | ||
| 55 | 45 | ||
| 56 | ret = osd_finalize_request(or, 0, cred, NULL); | 46 | MODULE_AUTHOR("Boaz Harrosh <bharrosh@panasas.com>"); |
| 57 | if (unlikely(ret)) { | 47 | MODULE_DESCRIPTION("Objects Raid Engine ore.ko"); |
| 58 | EXOFS_DBGMSG("Failed to osd_finalize_request() => %d\n", ret); | 48 | MODULE_LICENSE("GPL"); |
| 59 | goto out; | ||
| 60 | } | ||
| 61 | 49 | ||
| 62 | ret = osd_execute_request(or); | 50 | static u8 *_ios_cred(struct ore_io_state *ios, unsigned index) |
| 63 | if (unlikely(ret)) | 51 | { |
| 64 | EXOFS_DBGMSG("osd_execute_request() => %d\n", ret); | 52 | return ios->comps->comps[index & ios->comps->single_comp].cred; |
| 65 | /* osd_req_decode_sense(or, ret); */ | 53 | } |
| 66 | 54 | ||
| 67 | out: | 55 | static struct osd_obj_id *_ios_obj(struct ore_io_state *ios, unsigned index) |
| 68 | osd_end_request(or); | 56 | { |
| 69 | return ret; | 57 | return &ios->comps->comps[index & ios->comps->single_comp].obj; |
| 70 | } | 58 | } |
| 71 | 59 | ||
| 72 | int exofs_get_io_state(struct exofs_layout *layout, | 60 | static struct osd_dev *_ios_od(struct ore_io_state *ios, unsigned index) |
| 73 | struct exofs_io_state **pios) | ||
| 74 | { | 61 | { |
| 75 | struct exofs_io_state *ios; | 62 | return ios->comps->ods[index]; |
| 63 | } | ||
| 64 | |||
| 65 | int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps, | ||
| 66 | bool is_reading, u64 offset, u64 length, | ||
| 67 | struct ore_io_state **pios) | ||
| 68 | { | ||
| 69 | struct ore_io_state *ios; | ||
| 76 | 70 | ||
| 77 | /*TODO: Maybe use kmem_cach per sbi of size | 71 | /*TODO: Maybe use kmem_cach per sbi of size |
| 78 | * exofs_io_state_size(layout->s_numdevs) | 72 | * exofs_io_state_size(layout->s_numdevs) |
| 79 | */ | 73 | */ |
| 80 | ios = kzalloc(exofs_io_state_size(layout->s_numdevs), GFP_KERNEL); | 74 | ios = kzalloc(ore_io_state_size(comps->numdevs), GFP_KERNEL); |
| 81 | if (unlikely(!ios)) { | 75 | if (unlikely(!ios)) { |
| 82 | EXOFS_DBGMSG("Failed kzalloc bytes=%d\n", | 76 | ORE_DBGMSG("Failed kzalloc bytes=%d\n", |
| 83 | exofs_io_state_size(layout->s_numdevs)); | 77 | ore_io_state_size(comps->numdevs)); |
| 84 | *pios = NULL; | 78 | *pios = NULL; |
| 85 | return -ENOMEM; | 79 | return -ENOMEM; |
| 86 | } | 80 | } |
| 87 | 81 | ||
| 88 | ios->layout = layout; | 82 | ios->layout = layout; |
| 89 | ios->obj.partition = layout->s_pid; | 83 | ios->comps = comps; |
| 84 | ios->offset = offset; | ||
| 85 | ios->length = length; | ||
| 86 | ios->reading = is_reading; | ||
| 87 | |||
| 90 | *pios = ios; | 88 | *pios = ios; |
| 91 | return 0; | 89 | return 0; |
| 92 | } | 90 | } |
| 91 | EXPORT_SYMBOL(ore_get_rw_state); | ||
| 92 | |||
| 93 | int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps, | ||
| 94 | struct ore_io_state **ios) | ||
| 95 | { | ||
| 96 | return ore_get_rw_state(layout, comps, true, 0, 0, ios); | ||
| 97 | } | ||
| 98 | EXPORT_SYMBOL(ore_get_io_state); | ||
| 93 | 99 | ||
| 94 | void exofs_put_io_state(struct exofs_io_state *ios) | 100 | void ore_put_io_state(struct ore_io_state *ios) |
| 95 | { | 101 | { |
| 96 | if (ios) { | 102 | if (ios) { |
| 97 | unsigned i; | 103 | unsigned i; |
| 98 | 104 | ||
| 99 | for (i = 0; i < ios->numdevs; i++) { | 105 | for (i = 0; i < ios->numdevs; i++) { |
| 100 | struct exofs_per_dev_state *per_dev = &ios->per_dev[i]; | 106 | struct ore_per_dev_state *per_dev = &ios->per_dev[i]; |
| 101 | 107 | ||
| 102 | if (per_dev->or) | 108 | if (per_dev->or) |
| 103 | osd_end_request(per_dev->or); | 109 | osd_end_request(per_dev->or); |
| @@ -108,31 +114,9 @@ void exofs_put_io_state(struct exofs_io_state *ios) | |||
| 108 | kfree(ios); | 114 | kfree(ios); |
| 109 | } | 115 | } |
| 110 | } | 116 | } |
| 117 | EXPORT_SYMBOL(ore_put_io_state); | ||
| 111 | 118 | ||
| 112 | unsigned exofs_layout_od_id(struct exofs_layout *layout, | 119 | static void _sync_done(struct ore_io_state *ios, void *p) |
| 113 | osd_id obj_no, unsigned layout_index) | ||
| 114 | { | ||
| 115 | /* switch (layout->lay_func) { | ||
| 116 | case LAYOUT_MOVING_WINDOW: | ||
| 117 | {*/ | ||
| 118 | unsigned dev_mod = obj_no; | ||
| 119 | |||
| 120 | return (layout_index + dev_mod * layout->mirrors_p1) % | ||
| 121 | layout->s_numdevs; | ||
| 122 | /* } | ||
| 123 | case LAYOUT_FUNC_IMPLICT: | ||
| 124 | return layout->devs[layout_index]; | ||
| 125 | }*/ | ||
| 126 | } | ||
| 127 | |||
| 128 | static inline struct osd_dev *exofs_ios_od(struct exofs_io_state *ios, | ||
| 129 | unsigned layout_index) | ||
| 130 | { | ||
| 131 | return ios->layout->s_ods[ | ||
| 132 | exofs_layout_od_id(ios->layout, ios->obj.id, layout_index)]; | ||
| 133 | } | ||
| 134 | |||
| 135 | static void _sync_done(struct exofs_io_state *ios, void *p) | ||
| 136 | { | 120 | { |
| 137 | struct completion *waiting = p; | 121 | struct completion *waiting = p; |
| 138 | 122 | ||
| @@ -141,20 +125,20 @@ static void _sync_done(struct exofs_io_state *ios, void *p) | |||
| 141 | 125 | ||
| 142 | static void _last_io(struct kref *kref) | 126 | static void _last_io(struct kref *kref) |
| 143 | { | 127 | { |
| 144 | struct exofs_io_state *ios = container_of( | 128 | struct ore_io_state *ios = container_of( |
| 145 | kref, struct exofs_io_state, kref); | 129 | kref, struct ore_io_state, kref); |
| 146 | 130 | ||
| 147 | ios->done(ios, ios->private); | 131 | ios->done(ios, ios->private); |
| 148 | } | 132 | } |
| 149 | 133 | ||
| 150 | static void _done_io(struct osd_request *or, void *p) | 134 | static void _done_io(struct osd_request *or, void *p) |
| 151 | { | 135 | { |
| 152 | struct exofs_io_state *ios = p; | 136 | struct ore_io_state *ios = p; |
| 153 | 137 | ||
| 154 | kref_put(&ios->kref, _last_io); | 138 | kref_put(&ios->kref, _last_io); |
| 155 | } | 139 | } |
| 156 | 140 | ||
| 157 | static int exofs_io_execute(struct exofs_io_state *ios) | 141 | static int ore_io_execute(struct ore_io_state *ios) |
| 158 | { | 142 | { |
| 159 | DECLARE_COMPLETION_ONSTACK(wait); | 143 | DECLARE_COMPLETION_ONSTACK(wait); |
| 160 | bool sync = (ios->done == NULL); | 144 | bool sync = (ios->done == NULL); |
| @@ -170,9 +154,9 @@ static int exofs_io_execute(struct exofs_io_state *ios) | |||
| 170 | if (unlikely(!or)) | 154 | if (unlikely(!or)) |
| 171 | continue; | 155 | continue; |
| 172 | 156 | ||
| 173 | ret = osd_finalize_request(or, 0, ios->cred, NULL); | 157 | ret = osd_finalize_request(or, 0, _ios_cred(ios, i), NULL); |
| 174 | if (unlikely(ret)) { | 158 | if (unlikely(ret)) { |
| 175 | EXOFS_DBGMSG("Failed to osd_finalize_request() => %d\n", | 159 | ORE_DBGMSG("Failed to osd_finalize_request() => %d\n", |
| 176 | ret); | 160 | ret); |
| 177 | return ret; | 161 | return ret; |
| 178 | } | 162 | } |
| @@ -194,7 +178,7 @@ static int exofs_io_execute(struct exofs_io_state *ios) | |||
| 194 | 178 | ||
| 195 | if (sync) { | 179 | if (sync) { |
| 196 | wait_for_completion(&wait); | 180 | wait_for_completion(&wait); |
| 197 | ret = exofs_check_io(ios, NULL); | 181 | ret = ore_check_io(ios, NULL); |
| 198 | } | 182 | } |
| 199 | return ret; | 183 | return ret; |
| 200 | } | 184 | } |
| @@ -214,7 +198,7 @@ static void _clear_bio(struct bio *bio) | |||
| 214 | } | 198 | } |
| 215 | } | 199 | } |
| 216 | 200 | ||
| 217 | int exofs_check_io(struct exofs_io_state *ios, u64 *resid) | 201 | int ore_check_io(struct ore_io_state *ios, u64 *resid) |
| 218 | { | 202 | { |
| 219 | enum osd_err_priority acumulated_osd_err = 0; | 203 | enum osd_err_priority acumulated_osd_err = 0; |
| 220 | int acumulated_lin_err = 0; | 204 | int acumulated_lin_err = 0; |
| @@ -235,7 +219,7 @@ int exofs_check_io(struct exofs_io_state *ios, u64 *resid) | |||
| 235 | if (OSD_ERR_PRI_CLEAR_PAGES == osi.osd_err_pri) { | 219 | if (OSD_ERR_PRI_CLEAR_PAGES == osi.osd_err_pri) { |
| 236 | /* start read offset passed endof file */ | 220 | /* start read offset passed endof file */ |
| 237 | _clear_bio(ios->per_dev[i].bio); | 221 | _clear_bio(ios->per_dev[i].bio); |
| 238 | EXOFS_DBGMSG("start read offset passed end of file " | 222 | ORE_DBGMSG("start read offset passed end of file " |
| 239 | "offset=0x%llx, length=0x%llx\n", | 223 | "offset=0x%llx, length=0x%llx\n", |
| 240 | _LLU(ios->per_dev[i].offset), | 224 | _LLU(ios->per_dev[i].offset), |
| 241 | _LLU(ios->per_dev[i].length)); | 225 | _LLU(ios->per_dev[i].length)); |
| @@ -259,6 +243,7 @@ int exofs_check_io(struct exofs_io_state *ios, u64 *resid) | |||
| 259 | 243 | ||
| 260 | return acumulated_lin_err; | 244 | return acumulated_lin_err; |
| 261 | } | 245 | } |
| 246 | EXPORT_SYMBOL(ore_check_io); | ||
| 262 | 247 | ||
| 263 | /* | 248 | /* |
| 264 | * L - logical offset into the file | 249 | * L - logical offset into the file |
| @@ -305,20 +290,21 @@ int exofs_check_io(struct exofs_io_state *ios, u64 *resid) | |||
| 305 | struct _striping_info { | 290 | struct _striping_info { |
| 306 | u64 obj_offset; | 291 | u64 obj_offset; |
| 307 | u64 group_length; | 292 | u64 group_length; |
| 293 | u64 M; /* for truncate */ | ||
| 308 | unsigned dev; | 294 | unsigned dev; |
| 309 | unsigned unit_off; | 295 | unsigned unit_off; |
| 310 | }; | 296 | }; |
| 311 | 297 | ||
| 312 | static void _calc_stripe_info(struct exofs_io_state *ios, u64 file_offset, | 298 | static void _calc_stripe_info(struct ore_layout *layout, u64 file_offset, |
| 313 | struct _striping_info *si) | 299 | struct _striping_info *si) |
| 314 | { | 300 | { |
| 315 | u32 stripe_unit = ios->layout->stripe_unit; | 301 | u32 stripe_unit = layout->stripe_unit; |
| 316 | u32 group_width = ios->layout->group_width; | 302 | u32 group_width = layout->group_width; |
| 317 | u64 group_depth = ios->layout->group_depth; | 303 | u64 group_depth = layout->group_depth; |
| 318 | 304 | ||
| 319 | u32 U = stripe_unit * group_width; | 305 | u32 U = stripe_unit * group_width; |
| 320 | u64 T = U * group_depth; | 306 | u64 T = U * group_depth; |
| 321 | u64 S = T * ios->layout->group_count; | 307 | u64 S = T * layout->group_count; |
| 322 | u64 M = div64_u64(file_offset, S); | 308 | u64 M = div64_u64(file_offset, S); |
| 323 | 309 | ||
| 324 | /* | 310 | /* |
| @@ -333,7 +319,7 @@ static void _calc_stripe_info(struct exofs_io_state *ios, u64 file_offset, | |||
| 333 | 319 | ||
| 334 | /* "H - (N * U)" is just "H % U" so it's bound to u32 */ | 320 | /* "H - (N * U)" is just "H % U" so it's bound to u32 */ |
| 335 | si->dev = (u32)(H - (N * U)) / stripe_unit + G * group_width; | 321 | si->dev = (u32)(H - (N * U)) / stripe_unit + G * group_width; |
| 336 | si->dev *= ios->layout->mirrors_p1; | 322 | si->dev *= layout->mirrors_p1; |
| 337 | 323 | ||
| 338 | div_u64_rem(file_offset, stripe_unit, &si->unit_off); | 324 | div_u64_rem(file_offset, stripe_unit, &si->unit_off); |
| 339 | 325 | ||
| @@ -341,15 +327,16 @@ static void _calc_stripe_info(struct exofs_io_state *ios, u64 file_offset, | |||
| 341 | (M * group_depth * stripe_unit); | 327 | (M * group_depth * stripe_unit); |
| 342 | 328 | ||
| 343 | si->group_length = T - H; | 329 | si->group_length = T - H; |
| 330 | si->M = M; | ||
| 344 | } | 331 | } |
| 345 | 332 | ||
| 346 | static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg, | 333 | static int _add_stripe_unit(struct ore_io_state *ios, unsigned *cur_pg, |
| 347 | unsigned pgbase, struct exofs_per_dev_state *per_dev, | 334 | unsigned pgbase, struct ore_per_dev_state *per_dev, |
| 348 | int cur_len) | 335 | int cur_len) |
| 349 | { | 336 | { |
| 350 | unsigned pg = *cur_pg; | 337 | unsigned pg = *cur_pg; |
| 351 | struct request_queue *q = | 338 | struct request_queue *q = |
| 352 | osd_request_queue(exofs_ios_od(ios, per_dev->dev)); | 339 | osd_request_queue(_ios_od(ios, per_dev->dev)); |
| 353 | 340 | ||
| 354 | per_dev->length += cur_len; | 341 | per_dev->length += cur_len; |
| 355 | 342 | ||
| @@ -361,7 +348,7 @@ static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg, | |||
| 361 | 348 | ||
| 362 | per_dev->bio = bio_kmalloc(GFP_KERNEL, bio_size); | 349 | per_dev->bio = bio_kmalloc(GFP_KERNEL, bio_size); |
| 363 | if (unlikely(!per_dev->bio)) { | 350 | if (unlikely(!per_dev->bio)) { |
| 364 | EXOFS_DBGMSG("Failed to allocate BIO size=%u\n", | 351 | ORE_DBGMSG("Failed to allocate BIO size=%u\n", |
| 365 | bio_size); | 352 | bio_size); |
| 366 | return -ENOMEM; | 353 | return -ENOMEM; |
| 367 | } | 354 | } |
| @@ -387,7 +374,7 @@ static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg, | |||
| 387 | return 0; | 374 | return 0; |
| 388 | } | 375 | } |
| 389 | 376 | ||
| 390 | static int _prepare_one_group(struct exofs_io_state *ios, u64 length, | 377 | static int _prepare_one_group(struct ore_io_state *ios, u64 length, |
| 391 | struct _striping_info *si) | 378 | struct _striping_info *si) |
| 392 | { | 379 | { |
| 393 | unsigned stripe_unit = ios->layout->stripe_unit; | 380 | unsigned stripe_unit = ios->layout->stripe_unit; |
| @@ -400,7 +387,7 @@ static int _prepare_one_group(struct exofs_io_state *ios, u64 length, | |||
| 400 | int ret = 0; | 387 | int ret = 0; |
| 401 | 388 | ||
| 402 | while (length) { | 389 | while (length) { |
| 403 | struct exofs_per_dev_state *per_dev = &ios->per_dev[dev]; | 390 | struct ore_per_dev_state *per_dev = &ios->per_dev[dev]; |
| 404 | unsigned cur_len, page_off = 0; | 391 | unsigned cur_len, page_off = 0; |
| 405 | 392 | ||
| 406 | if (!per_dev->length) { | 393 | if (!per_dev->length) { |
| @@ -443,7 +430,7 @@ out: | |||
| 443 | return ret; | 430 | return ret; |
| 444 | } | 431 | } |
| 445 | 432 | ||
| 446 | static int _prepare_for_striping(struct exofs_io_state *ios) | 433 | static int _prepare_for_striping(struct ore_io_state *ios) |
| 447 | { | 434 | { |
| 448 | u64 length = ios->length; | 435 | u64 length = ios->length; |
| 449 | u64 offset = ios->offset; | 436 | u64 offset = ios->offset; |
| @@ -452,9 +439,9 @@ static int _prepare_for_striping(struct exofs_io_state *ios) | |||
| 452 | 439 | ||
| 453 | if (!ios->pages) { | 440 | if (!ios->pages) { |
| 454 | if (ios->kern_buff) { | 441 | if (ios->kern_buff) { |
| 455 | struct exofs_per_dev_state *per_dev = &ios->per_dev[0]; | 442 | struct ore_per_dev_state *per_dev = &ios->per_dev[0]; |
| 456 | 443 | ||
| 457 | _calc_stripe_info(ios, ios->offset, &si); | 444 | _calc_stripe_info(ios->layout, ios->offset, &si); |
| 458 | per_dev->offset = si.obj_offset; | 445 | per_dev->offset = si.obj_offset; |
| 459 | per_dev->dev = si.dev; | 446 | per_dev->dev = si.dev; |
| 460 | 447 | ||
| @@ -468,7 +455,7 @@ static int _prepare_for_striping(struct exofs_io_state *ios) | |||
| 468 | } | 455 | } |
| 469 | 456 | ||
| 470 | while (length) { | 457 | while (length) { |
| 471 | _calc_stripe_info(ios, offset, &si); | 458 | _calc_stripe_info(ios->layout, offset, &si); |
| 472 | 459 | ||
| 473 | if (length < si.group_length) | 460 | if (length < si.group_length) |
| 474 | si.group_length = length; | 461 | si.group_length = length; |
| @@ -485,57 +472,59 @@ out: | |||
| 485 | return ret; | 472 | return ret; |
| 486 | } | 473 | } |
| 487 | 474 | ||
| 488 | int exofs_sbi_create(struct exofs_io_state *ios) | 475 | int ore_create(struct ore_io_state *ios) |
| 489 | { | 476 | { |
| 490 | int i, ret; | 477 | int i, ret; |
| 491 | 478 | ||
| 492 | for (i = 0; i < ios->layout->s_numdevs; i++) { | 479 | for (i = 0; i < ios->comps->numdevs; i++) { |
| 493 | struct osd_request *or; | 480 | struct osd_request *or; |
| 494 | 481 | ||
| 495 | or = osd_start_request(exofs_ios_od(ios, i), GFP_KERNEL); | 482 | or = osd_start_request(_ios_od(ios, i), GFP_KERNEL); |
| 496 | if (unlikely(!or)) { | 483 | if (unlikely(!or)) { |
| 497 | EXOFS_ERR("%s: osd_start_request failed\n", __func__); | 484 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
| 498 | ret = -ENOMEM; | 485 | ret = -ENOMEM; |
| 499 | goto out; | 486 | goto out; |
| 500 | } | 487 | } |
| 501 | ios->per_dev[i].or = or; | 488 | ios->per_dev[i].or = or; |
| 502 | ios->numdevs++; | 489 | ios->numdevs++; |
| 503 | 490 | ||
| 504 | osd_req_create_object(or, &ios->obj); | 491 | osd_req_create_object(or, _ios_obj(ios, i)); |
| 505 | } | 492 | } |
| 506 | ret = exofs_io_execute(ios); | 493 | ret = ore_io_execute(ios); |
| 507 | 494 | ||
| 508 | out: | 495 | out: |
| 509 | return ret; | 496 | return ret; |
| 510 | } | 497 | } |
| 498 | EXPORT_SYMBOL(ore_create); | ||
| 511 | 499 | ||
| 512 | int exofs_sbi_remove(struct exofs_io_state *ios) | 500 | int ore_remove(struct ore_io_state *ios) |
| 513 | { | 501 | { |
| 514 | int i, ret; | 502 | int i, ret; |
| 515 | 503 | ||
| 516 | for (i = 0; i < ios->layout->s_numdevs; i++) { | 504 | for (i = 0; i < ios->comps->numdevs; i++) { |
| 517 | struct osd_request *or; | 505 | struct osd_request *or; |
| 518 | 506 | ||
| 519 | or = osd_start_request(exofs_ios_od(ios, i), GFP_KERNEL); | 507 | or = osd_start_request(_ios_od(ios, i), GFP_KERNEL); |
| 520 | if (unlikely(!or)) { | 508 | if (unlikely(!or)) { |
| 521 | EXOFS_ERR("%s: osd_start_request failed\n", __func__); | 509 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
| 522 | ret = -ENOMEM; | 510 | ret = -ENOMEM; |
| 523 | goto out; | 511 | goto out; |
| 524 | } | 512 | } |
| 525 | ios->per_dev[i].or = or; | 513 | ios->per_dev[i].or = or; |
| 526 | ios->numdevs++; | 514 | ios->numdevs++; |
| 527 | 515 | ||
| 528 | osd_req_remove_object(or, &ios->obj); | 516 | osd_req_remove_object(or, _ios_obj(ios, i)); |
| 529 | } | 517 | } |
| 530 | ret = exofs_io_execute(ios); | 518 | ret = ore_io_execute(ios); |
| 531 | 519 | ||
| 532 | out: | 520 | out: |
| 533 | return ret; | 521 | return ret; |
| 534 | } | 522 | } |
| 523 | EXPORT_SYMBOL(ore_remove); | ||
| 535 | 524 | ||
| 536 | static int _sbi_write_mirror(struct exofs_io_state *ios, int cur_comp) | 525 | static int _write_mirror(struct ore_io_state *ios, int cur_comp) |
| 537 | { | 526 | { |
| 538 | struct exofs_per_dev_state *master_dev = &ios->per_dev[cur_comp]; | 527 | struct ore_per_dev_state *master_dev = &ios->per_dev[cur_comp]; |
| 539 | unsigned dev = ios->per_dev[cur_comp].dev; | 528 | unsigned dev = ios->per_dev[cur_comp].dev; |
| 540 | unsigned last_comp = cur_comp + ios->layout->mirrors_p1; | 529 | unsigned last_comp = cur_comp + ios->layout->mirrors_p1; |
| 541 | int ret = 0; | 530 | int ret = 0; |
| @@ -544,12 +533,12 @@ static int _sbi_write_mirror(struct exofs_io_state *ios, int cur_comp) | |||
| 544 | return 0; /* Just an empty slot */ | 533 | return 0; /* Just an empty slot */ |
| 545 | 534 | ||
| 546 | for (; cur_comp < last_comp; ++cur_comp, ++dev) { | 535 | for (; cur_comp < last_comp; ++cur_comp, ++dev) { |
| 547 | struct exofs_per_dev_state *per_dev = &ios->per_dev[cur_comp]; | 536 | struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp]; |
| 548 | struct osd_request *or; | 537 | struct osd_request *or; |
| 549 | 538 | ||
| 550 | or = osd_start_request(exofs_ios_od(ios, dev), GFP_KERNEL); | 539 | or = osd_start_request(_ios_od(ios, dev), GFP_KERNEL); |
| 551 | if (unlikely(!or)) { | 540 | if (unlikely(!or)) { |
| 552 | EXOFS_ERR("%s: osd_start_request failed\n", __func__); | 541 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
| 553 | ret = -ENOMEM; | 542 | ret = -ENOMEM; |
| 554 | goto out; | 543 | goto out; |
| 555 | } | 544 | } |
| @@ -563,7 +552,7 @@ static int _sbi_write_mirror(struct exofs_io_state *ios, int cur_comp) | |||
| 563 | bio = bio_kmalloc(GFP_KERNEL, | 552 | bio = bio_kmalloc(GFP_KERNEL, |
| 564 | master_dev->bio->bi_max_vecs); | 553 | master_dev->bio->bi_max_vecs); |
| 565 | if (unlikely(!bio)) { | 554 | if (unlikely(!bio)) { |
| 566 | EXOFS_DBGMSG( | 555 | ORE_DBGMSG( |
| 567 | "Failed to allocate BIO size=%u\n", | 556 | "Failed to allocate BIO size=%u\n", |
| 568 | master_dev->bio->bi_max_vecs); | 557 | master_dev->bio->bi_max_vecs); |
| 569 | ret = -ENOMEM; | 558 | ret = -ENOMEM; |
| @@ -582,25 +571,29 @@ static int _sbi_write_mirror(struct exofs_io_state *ios, int cur_comp) | |||
| 582 | bio->bi_rw |= REQ_WRITE; | 571 | bio->bi_rw |= REQ_WRITE; |
| 583 | } | 572 | } |
| 584 | 573 | ||
| 585 | osd_req_write(or, &ios->obj, per_dev->offset, bio, | 574 | osd_req_write(or, _ios_obj(ios, dev), per_dev->offset, |
| 586 | per_dev->length); | 575 | bio, per_dev->length); |
| 587 | EXOFS_DBGMSG("write(0x%llx) offset=0x%llx " | 576 | ORE_DBGMSG("write(0x%llx) offset=0x%llx " |
| 588 | "length=0x%llx dev=%d\n", | 577 | "length=0x%llx dev=%d\n", |
| 589 | _LLU(ios->obj.id), _LLU(per_dev->offset), | 578 | _LLU(_ios_obj(ios, dev)->id), |
| 579 | _LLU(per_dev->offset), | ||
| 590 | _LLU(per_dev->length), dev); | 580 | _LLU(per_dev->length), dev); |
| 591 | } else if (ios->kern_buff) { | 581 | } else if (ios->kern_buff) { |
| 592 | ret = osd_req_write_kern(or, &ios->obj, per_dev->offset, | 582 | ret = osd_req_write_kern(or, _ios_obj(ios, dev), |
| 593 | ios->kern_buff, ios->length); | 583 | per_dev->offset, |
| 584 | ios->kern_buff, ios->length); | ||
| 594 | if (unlikely(ret)) | 585 | if (unlikely(ret)) |
| 595 | goto out; | 586 | goto out; |
| 596 | EXOFS_DBGMSG2("write_kern(0x%llx) offset=0x%llx " | 587 | ORE_DBGMSG2("write_kern(0x%llx) offset=0x%llx " |
| 597 | "length=0x%llx dev=%d\n", | 588 | "length=0x%llx dev=%d\n", |
| 598 | _LLU(ios->obj.id), _LLU(per_dev->offset), | 589 | _LLU(_ios_obj(ios, dev)->id), |
| 590 | _LLU(per_dev->offset), | ||
| 599 | _LLU(ios->length), dev); | 591 | _LLU(ios->length), dev); |
| 600 | } else { | 592 | } else { |
| 601 | osd_req_set_attributes(or, &ios->obj); | 593 | osd_req_set_attributes(or, _ios_obj(ios, dev)); |
| 602 | EXOFS_DBGMSG2("obj(0x%llx) set_attributes=%d dev=%d\n", | 594 | ORE_DBGMSG2("obj(0x%llx) set_attributes=%d dev=%d\n", |
| 603 | _LLU(ios->obj.id), ios->out_attr_len, dev); | 595 | _LLU(_ios_obj(ios, dev)->id), |
| 596 | ios->out_attr_len, dev); | ||
| 604 | } | 597 | } |
| 605 | 598 | ||
| 606 | if (ios->out_attr) | 599 | if (ios->out_attr) |
| @@ -616,7 +609,7 @@ out: | |||
| 616 | return ret; | 609 | return ret; |
| 617 | } | 610 | } |
| 618 | 611 | ||
| 619 | int exofs_sbi_write(struct exofs_io_state *ios) | 612 | int ore_write(struct ore_io_state *ios) |
| 620 | { | 613 | { |
| 621 | int i; | 614 | int i; |
| 622 | int ret; | 615 | int ret; |
| @@ -626,52 +619,55 @@ int exofs_sbi_write(struct exofs_io_state *ios) | |||
| 626 | return ret; | 619 | return ret; |
| 627 | 620 | ||
| 628 | for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) { | 621 | for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) { |
| 629 | ret = _sbi_write_mirror(ios, i); | 622 | ret = _write_mirror(ios, i); |
| 630 | if (unlikely(ret)) | 623 | if (unlikely(ret)) |
| 631 | return ret; | 624 | return ret; |
| 632 | } | 625 | } |
| 633 | 626 | ||
| 634 | ret = exofs_io_execute(ios); | 627 | ret = ore_io_execute(ios); |
| 635 | return ret; | 628 | return ret; |
| 636 | } | 629 | } |
| 630 | EXPORT_SYMBOL(ore_write); | ||
| 637 | 631 | ||
| 638 | static int _sbi_read_mirror(struct exofs_io_state *ios, unsigned cur_comp) | 632 | static int _read_mirror(struct ore_io_state *ios, unsigned cur_comp) |
| 639 | { | 633 | { |
| 640 | struct osd_request *or; | 634 | struct osd_request *or; |
| 641 | struct exofs_per_dev_state *per_dev = &ios->per_dev[cur_comp]; | 635 | struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp]; |
| 642 | unsigned first_dev = (unsigned)ios->obj.id; | 636 | struct osd_obj_id *obj = _ios_obj(ios, cur_comp); |
| 637 | unsigned first_dev = (unsigned)obj->id; | ||
| 643 | 638 | ||
| 644 | if (ios->pages && !per_dev->length) | 639 | if (ios->pages && !per_dev->length) |
| 645 | return 0; /* Just an empty slot */ | 640 | return 0; /* Just an empty slot */ |
| 646 | 641 | ||
| 647 | first_dev = per_dev->dev + first_dev % ios->layout->mirrors_p1; | 642 | first_dev = per_dev->dev + first_dev % ios->layout->mirrors_p1; |
| 648 | or = osd_start_request(exofs_ios_od(ios, first_dev), GFP_KERNEL); | 643 | or = osd_start_request(_ios_od(ios, first_dev), GFP_KERNEL); |
| 649 | if (unlikely(!or)) { | 644 | if (unlikely(!or)) { |
| 650 | EXOFS_ERR("%s: osd_start_request failed\n", __func__); | 645 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
| 651 | return -ENOMEM; | 646 | return -ENOMEM; |
| 652 | } | 647 | } |
| 653 | per_dev->or = or; | 648 | per_dev->or = or; |
| 654 | 649 | ||
| 655 | if (ios->pages) { | 650 | if (ios->pages) { |
| 656 | osd_req_read(or, &ios->obj, per_dev->offset, | 651 | osd_req_read(or, obj, per_dev->offset, |
| 657 | per_dev->bio, per_dev->length); | 652 | per_dev->bio, per_dev->length); |
| 658 | EXOFS_DBGMSG("read(0x%llx) offset=0x%llx length=0x%llx" | 653 | ORE_DBGMSG("read(0x%llx) offset=0x%llx length=0x%llx" |
| 659 | " dev=%d\n", _LLU(ios->obj.id), | 654 | " dev=%d\n", _LLU(obj->id), |
| 660 | _LLU(per_dev->offset), _LLU(per_dev->length), | 655 | _LLU(per_dev->offset), _LLU(per_dev->length), |
| 661 | first_dev); | 656 | first_dev); |
| 662 | } else if (ios->kern_buff) { | 657 | } else if (ios->kern_buff) { |
| 663 | int ret = osd_req_read_kern(or, &ios->obj, per_dev->offset, | 658 | int ret = osd_req_read_kern(or, obj, per_dev->offset, |
| 664 | ios->kern_buff, ios->length); | 659 | ios->kern_buff, ios->length); |
| 665 | EXOFS_DBGMSG2("read_kern(0x%llx) offset=0x%llx " | 660 | ORE_DBGMSG2("read_kern(0x%llx) offset=0x%llx " |
| 666 | "length=0x%llx dev=%d ret=>%d\n", | 661 | "length=0x%llx dev=%d ret=>%d\n", |
| 667 | _LLU(ios->obj.id), _LLU(per_dev->offset), | 662 | _LLU(obj->id), _LLU(per_dev->offset), |
| 668 | _LLU(ios->length), first_dev, ret); | 663 | _LLU(ios->length), first_dev, ret); |
| 669 | if (unlikely(ret)) | 664 | if (unlikely(ret)) |
| 670 | return ret; | 665 | return ret; |
| 671 | } else { | 666 | } else { |
| 672 | osd_req_get_attributes(or, &ios->obj); | 667 | osd_req_get_attributes(or, obj); |
| 673 | EXOFS_DBGMSG2("obj(0x%llx) get_attributes=%d dev=%d\n", | 668 | ORE_DBGMSG2("obj(0x%llx) get_attributes=%d dev=%d\n", |
| 674 | _LLU(ios->obj.id), ios->in_attr_len, first_dev); | 669 | _LLU(obj->id), |
| 670 | ios->in_attr_len, first_dev); | ||
| 675 | } | 671 | } |
| 676 | if (ios->out_attr) | 672 | if (ios->out_attr) |
| 677 | osd_req_add_set_attr_list(or, ios->out_attr, ios->out_attr_len); | 673 | osd_req_add_set_attr_list(or, ios->out_attr, ios->out_attr_len); |
| @@ -682,7 +678,7 @@ static int _sbi_read_mirror(struct exofs_io_state *ios, unsigned cur_comp) | |||
| 682 | return 0; | 678 | return 0; |
| 683 | } | 679 | } |
| 684 | 680 | ||
| 685 | int exofs_sbi_read(struct exofs_io_state *ios) | 681 | int ore_read(struct ore_io_state *ios) |
| 686 | { | 682 | { |
| 687 | int i; | 683 | int i; |
| 688 | int ret; | 684 | int ret; |
| @@ -692,16 +688,17 @@ int exofs_sbi_read(struct exofs_io_state *ios) | |||
| 692 | return ret; | 688 | return ret; |
| 693 | 689 | ||
| 694 | for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) { | 690 | for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) { |
| 695 | ret = _sbi_read_mirror(ios, i); | 691 | ret = _read_mirror(ios, i); |
| 696 | if (unlikely(ret)) | 692 | if (unlikely(ret)) |
| 697 | return ret; | 693 | return ret; |
| 698 | } | 694 | } |
| 699 | 695 | ||
| 700 | ret = exofs_io_execute(ios); | 696 | ret = ore_io_execute(ios); |
| 701 | return ret; | 697 | return ret; |
| 702 | } | 698 | } |
| 699 | EXPORT_SYMBOL(ore_read); | ||
| 703 | 700 | ||
| 704 | int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr) | 701 | int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr) |
| 705 | { | 702 | { |
| 706 | struct osd_attr cur_attr = {.attr_page = 0}; /* start with zeros */ | 703 | struct osd_attr cur_attr = {.attr_page = 0}; /* start with zeros */ |
| 707 | void *iter = NULL; | 704 | void *iter = NULL; |
| @@ -721,83 +718,118 @@ int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr) | |||
| 721 | 718 | ||
| 722 | return -EIO; | 719 | return -EIO; |
| 723 | } | 720 | } |
| 721 | EXPORT_SYMBOL(extract_attr_from_ios); | ||
| 724 | 722 | ||
| 725 | static int _truncate_mirrors(struct exofs_io_state *ios, unsigned cur_comp, | 723 | static int _truncate_mirrors(struct ore_io_state *ios, unsigned cur_comp, |
| 726 | struct osd_attr *attr) | 724 | struct osd_attr *attr) |
| 727 | { | 725 | { |
| 728 | int last_comp = cur_comp + ios->layout->mirrors_p1; | 726 | int last_comp = cur_comp + ios->layout->mirrors_p1; |
| 729 | 727 | ||
| 730 | for (; cur_comp < last_comp; ++cur_comp) { | 728 | for (; cur_comp < last_comp; ++cur_comp) { |
| 731 | struct exofs_per_dev_state *per_dev = &ios->per_dev[cur_comp]; | 729 | struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp]; |
| 732 | struct osd_request *or; | 730 | struct osd_request *or; |
| 733 | 731 | ||
| 734 | or = osd_start_request(exofs_ios_od(ios, cur_comp), GFP_KERNEL); | 732 | or = osd_start_request(_ios_od(ios, cur_comp), GFP_KERNEL); |
| 735 | if (unlikely(!or)) { | 733 | if (unlikely(!or)) { |
| 736 | EXOFS_ERR("%s: osd_start_request failed\n", __func__); | 734 | ORE_ERR("%s: osd_start_request failed\n", __func__); |
| 737 | return -ENOMEM; | 735 | return -ENOMEM; |
| 738 | } | 736 | } |
| 739 | per_dev->or = or; | 737 | per_dev->or = or; |
| 740 | 738 | ||
| 741 | osd_req_set_attributes(or, &ios->obj); | 739 | osd_req_set_attributes(or, _ios_obj(ios, cur_comp)); |
| 742 | osd_req_add_set_attr_list(or, attr, 1); | 740 | osd_req_add_set_attr_list(or, attr, 1); |
| 743 | } | 741 | } |
| 744 | 742 | ||
| 745 | return 0; | 743 | return 0; |
| 746 | } | 744 | } |
| 747 | 745 | ||
| 748 | int exofs_oi_truncate(struct exofs_i_info *oi, u64 size) | 746 | struct _trunc_info { |
| 747 | struct _striping_info si; | ||
| 748 | u64 prev_group_obj_off; | ||
| 749 | u64 next_group_obj_off; | ||
| 750 | |||
| 751 | unsigned first_group_dev; | ||
| 752 | unsigned nex_group_dev; | ||
| 753 | unsigned max_devs; | ||
| 754 | }; | ||
| 755 | |||
| 756 | void _calc_trunk_info(struct ore_layout *layout, u64 file_offset, | ||
| 757 | struct _trunc_info *ti) | ||
| 758 | { | ||
| 759 | unsigned stripe_unit = layout->stripe_unit; | ||
| 760 | |||
| 761 | _calc_stripe_info(layout, file_offset, &ti->si); | ||
| 762 | |||
| 763 | ti->prev_group_obj_off = ti->si.M * stripe_unit; | ||
| 764 | ti->next_group_obj_off = ti->si.M ? (ti->si.M - 1) * stripe_unit : 0; | ||
| 765 | |||
| 766 | ti->first_group_dev = ti->si.dev - (ti->si.dev % layout->group_width); | ||
| 767 | ti->nex_group_dev = ti->first_group_dev + layout->group_width; | ||
| 768 | ti->max_devs = layout->group_width * layout->group_count; | ||
| 769 | } | ||
| 770 | |||
| 771 | int ore_truncate(struct ore_layout *layout, struct ore_components *comps, | ||
| 772 | u64 size) | ||
| 749 | { | 773 | { |
| 750 | struct exofs_sb_info *sbi = oi->vfs_inode.i_sb->s_fs_info; | 774 | struct ore_io_state *ios; |
| 751 | struct exofs_io_state *ios; | ||
| 752 | struct exofs_trunc_attr { | 775 | struct exofs_trunc_attr { |
| 753 | struct osd_attr attr; | 776 | struct osd_attr attr; |
| 754 | __be64 newsize; | 777 | __be64 newsize; |
| 755 | } *size_attrs; | 778 | } *size_attrs; |
| 756 | struct _striping_info si; | 779 | struct _trunc_info ti; |
| 757 | int i, ret; | 780 | int i, ret; |
| 758 | 781 | ||
| 759 | ret = exofs_get_io_state(&sbi->layout, &ios); | 782 | ret = ore_get_io_state(layout, comps, &ios); |
| 760 | if (unlikely(ret)) | 783 | if (unlikely(ret)) |
| 761 | return ret; | 784 | return ret; |
| 762 | 785 | ||
| 763 | size_attrs = kcalloc(ios->layout->group_width, sizeof(*size_attrs), | 786 | _calc_trunk_info(ios->layout, size, &ti); |
| 787 | |||
| 788 | size_attrs = kcalloc(ti.max_devs, sizeof(*size_attrs), | ||
| 764 | GFP_KERNEL); | 789 | GFP_KERNEL); |
| 765 | if (unlikely(!size_attrs)) { | 790 | if (unlikely(!size_attrs)) { |
| 766 | ret = -ENOMEM; | 791 | ret = -ENOMEM; |
| 767 | goto out; | 792 | goto out; |
| 768 | } | 793 | } |
| 769 | 794 | ||
| 770 | ios->obj.id = exofs_oi_objno(oi); | 795 | ios->numdevs = ios->comps->numdevs; |
| 771 | ios->cred = oi->i_cred; | ||
| 772 | 796 | ||
| 773 | ios->numdevs = ios->layout->s_numdevs; | 797 | for (i = 0; i < ti.max_devs; ++i) { |
| 774 | _calc_stripe_info(ios, size, &si); | ||
| 775 | |||
| 776 | for (i = 0; i < ios->layout->group_width; ++i) { | ||
| 777 | struct exofs_trunc_attr *size_attr = &size_attrs[i]; | 798 | struct exofs_trunc_attr *size_attr = &size_attrs[i]; |
| 778 | u64 obj_size; | 799 | u64 obj_size; |
| 779 | 800 | ||
| 780 | if (i < si.dev) | 801 | if (i < ti.first_group_dev) |
| 781 | obj_size = si.obj_offset + | 802 | obj_size = ti.prev_group_obj_off; |
| 782 | ios->layout->stripe_unit - si.unit_off; | 803 | else if (i >= ti.nex_group_dev) |
| 783 | else if (i == si.dev) | 804 | obj_size = ti.next_group_obj_off; |
| 784 | obj_size = si.obj_offset; | 805 | else if (i < ti.si.dev) /* dev within this group */ |
| 785 | else /* i > si.dev */ | 806 | obj_size = ti.si.obj_offset + |
| 786 | obj_size = si.obj_offset - si.unit_off; | 807 | ios->layout->stripe_unit - ti.si.unit_off; |
| 808 | else if (i == ti.si.dev) | ||
| 809 | obj_size = ti.si.obj_offset; | ||
| 810 | else /* i > ti.dev */ | ||
| 811 | obj_size = ti.si.obj_offset - ti.si.unit_off; | ||
| 787 | 812 | ||
| 788 | size_attr->newsize = cpu_to_be64(obj_size); | 813 | size_attr->newsize = cpu_to_be64(obj_size); |
| 789 | size_attr->attr = g_attr_logical_length; | 814 | size_attr->attr = g_attr_logical_length; |
| 790 | size_attr->attr.val_ptr = &size_attr->newsize; | 815 | size_attr->attr.val_ptr = &size_attr->newsize; |
| 791 | 816 | ||
| 817 | ORE_DBGMSG("trunc(0x%llx) obj_offset=0x%llx dev=%d\n", | ||
| 818 | _LLU(comps->comps->obj.id), _LLU(obj_size), i); | ||
| 792 | ret = _truncate_mirrors(ios, i * ios->layout->mirrors_p1, | 819 | ret = _truncate_mirrors(ios, i * ios->layout->mirrors_p1, |
| 793 | &size_attr->attr); | 820 | &size_attr->attr); |
| 794 | if (unlikely(ret)) | 821 | if (unlikely(ret)) |
| 795 | goto out; | 822 | goto out; |
| 796 | } | 823 | } |
| 797 | ret = exofs_io_execute(ios); | 824 | ret = ore_io_execute(ios); |
| 798 | 825 | ||
| 799 | out: | 826 | out: |
| 800 | kfree(size_attrs); | 827 | kfree(size_attrs); |
| 801 | exofs_put_io_state(ios); | 828 | ore_put_io_state(ios); |
| 802 | return ret; | 829 | return ret; |
| 803 | } | 830 | } |
| 831 | EXPORT_SYMBOL(ore_truncate); | ||
| 832 | |||
| 833 | const struct osd_attr g_attr_logical_length = ATTR_DEF( | ||
| 834 | OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8); | ||
| 835 | EXPORT_SYMBOL(g_attr_logical_length); | ||
diff --git a/fs/exofs/pnfs.h b/fs/exofs/pnfs.h deleted file mode 100644 index c52e9888b8ab..000000000000 --- a/fs/exofs/pnfs.h +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2008, 2009 | ||
| 3 | * Boaz Harrosh <bharrosh@panasas.com> | ||
| 4 | * | ||
| 5 | * This file is part of exofs. | ||
| 6 | * | ||
| 7 | * exofs is free software; you can redistribute it and/or modify it under the | ||
| 8 | * terms of the GNU General Public License version 2 as published by the Free | ||
| 9 | * Software Foundation. | ||
| 10 | * | ||
| 11 | */ | ||
| 12 | |||
| 13 | /* FIXME: Remove this file once pnfs hits mainline */ | ||
| 14 | |||
| 15 | #ifndef __EXOFS_PNFS_H__ | ||
| 16 | #define __EXOFS_PNFS_H__ | ||
| 17 | |||
| 18 | #if ! defined(__PNFS_OSD_XDR_H__) | ||
| 19 | |||
| 20 | enum pnfs_iomode { | ||
| 21 | IOMODE_READ = 1, | ||
| 22 | IOMODE_RW = 2, | ||
| 23 | IOMODE_ANY = 3, | ||
| 24 | }; | ||
| 25 | |||
| 26 | /* Layout Structure */ | ||
| 27 | enum pnfs_osd_raid_algorithm4 { | ||
| 28 | PNFS_OSD_RAID_0 = 1, | ||
| 29 | PNFS_OSD_RAID_4 = 2, | ||
| 30 | PNFS_OSD_RAID_5 = 3, | ||
| 31 | PNFS_OSD_RAID_PQ = 4 /* Reed-Solomon P+Q */ | ||
| 32 | }; | ||
| 33 | |||
| 34 | struct pnfs_osd_data_map { | ||
| 35 | u32 odm_num_comps; | ||
| 36 | u64 odm_stripe_unit; | ||
| 37 | u32 odm_group_width; | ||
| 38 | u32 odm_group_depth; | ||
| 39 | u32 odm_mirror_cnt; | ||
| 40 | u32 odm_raid_algorithm; | ||
| 41 | }; | ||
| 42 | |||
| 43 | #endif /* ! defined(__PNFS_OSD_XDR_H__) */ | ||
| 44 | |||
| 45 | #endif /* __EXOFS_PNFS_H__ */ | ||
diff --git a/fs/exofs/super.c b/fs/exofs/super.c index c57beddcc217..274894053b02 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c | |||
| @@ -40,6 +40,8 @@ | |||
| 40 | 40 | ||
| 41 | #include "exofs.h" | 41 | #include "exofs.h" |
| 42 | 42 | ||
| 43 | #define EXOFS_DBGMSG2(M...) do {} while (0) | ||
| 44 | |||
| 43 | /****************************************************************************** | 45 | /****************************************************************************** |
| 44 | * MOUNT OPTIONS | 46 | * MOUNT OPTIONS |
| 45 | *****************************************************************************/ | 47 | *****************************************************************************/ |
| @@ -208,10 +210,48 @@ static void destroy_inodecache(void) | |||
| 208 | } | 210 | } |
| 209 | 211 | ||
| 210 | /****************************************************************************** | 212 | /****************************************************************************** |
| 211 | * SUPERBLOCK FUNCTIONS | 213 | * Some osd helpers |
| 212 | *****************************************************************************/ | 214 | *****************************************************************************/ |
| 213 | static const struct super_operations exofs_sops; | 215 | void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], const struct osd_obj_id *obj) |
| 214 | static const struct export_operations exofs_export_ops; | 216 | { |
| 217 | osd_sec_init_nosec_doall_caps(cred_a, obj, false, true); | ||
| 218 | } | ||
| 219 | |||
| 220 | static int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj, | ||
| 221 | u64 offset, void *p, unsigned length) | ||
| 222 | { | ||
| 223 | struct osd_request *or = osd_start_request(od, GFP_KERNEL); | ||
| 224 | /* struct osd_sense_info osi = {.key = 0};*/ | ||
| 225 | int ret; | ||
| 226 | |||
| 227 | if (unlikely(!or)) { | ||
| 228 | EXOFS_DBGMSG("%s: osd_start_request failed.\n", __func__); | ||
| 229 | return -ENOMEM; | ||
| 230 | } | ||
| 231 | ret = osd_req_read_kern(or, obj, offset, p, length); | ||
| 232 | if (unlikely(ret)) { | ||
| 233 | EXOFS_DBGMSG("%s: osd_req_read_kern failed.\n", __func__); | ||
| 234 | goto out; | ||
| 235 | } | ||
| 236 | |||
| 237 | ret = osd_finalize_request(or, 0, cred, NULL); | ||
| 238 | if (unlikely(ret)) { | ||
| 239 | EXOFS_DBGMSG("Failed to osd_finalize_request() => %d\n", ret); | ||
| 240 | goto out; | ||
| 241 | } | ||
| 242 | |||
| 243 | ret = osd_execute_request(or); | ||
| 244 | if (unlikely(ret)) | ||
| 245 | EXOFS_DBGMSG("osd_execute_request() => %d\n", ret); | ||
| 246 | /* osd_req_decode_sense(or, ret); */ | ||
| 247 | |||
| 248 | out: | ||
| 249 | osd_end_request(or); | ||
| 250 | EXOFS_DBGMSG2("read_kern(0x%llx) offset=0x%llx " | ||
| 251 | "length=0x%llx dev=%p ret=>%d\n", | ||
| 252 | _LLU(obj->id), _LLU(offset), _LLU(length), od, ret); | ||
| 253 | return ret; | ||
| 254 | } | ||
| 215 | 255 | ||
| 216 | static const struct osd_attr g_attr_sb_stats = ATTR_DEF( | 256 | static const struct osd_attr g_attr_sb_stats = ATTR_DEF( |
| 217 | EXOFS_APAGE_SB_DATA, | 257 | EXOFS_APAGE_SB_DATA, |
| @@ -223,21 +263,19 @@ static int __sbi_read_stats(struct exofs_sb_info *sbi) | |||
| 223 | struct osd_attr attrs[] = { | 263 | struct osd_attr attrs[] = { |
| 224 | [0] = g_attr_sb_stats, | 264 | [0] = g_attr_sb_stats, |
| 225 | }; | 265 | }; |
| 226 | struct exofs_io_state *ios; | 266 | struct ore_io_state *ios; |
| 227 | int ret; | 267 | int ret; |
| 228 | 268 | ||
| 229 | ret = exofs_get_io_state(&sbi->layout, &ios); | 269 | ret = ore_get_io_state(&sbi->layout, &sbi->comps, &ios); |
| 230 | if (unlikely(ret)) { | 270 | if (unlikely(ret)) { |
| 231 | EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__); | 271 | EXOFS_ERR("%s: ore_get_io_state failed.\n", __func__); |
| 232 | return ret; | 272 | return ret; |
| 233 | } | 273 | } |
| 234 | 274 | ||
| 235 | ios->cred = sbi->s_cred; | ||
| 236 | |||
| 237 | ios->in_attr = attrs; | 275 | ios->in_attr = attrs; |
| 238 | ios->in_attr_len = ARRAY_SIZE(attrs); | 276 | ios->in_attr_len = ARRAY_SIZE(attrs); |
| 239 | 277 | ||
| 240 | ret = exofs_sbi_read(ios); | 278 | ret = ore_read(ios); |
| 241 | if (unlikely(ret)) { | 279 | if (unlikely(ret)) { |
| 242 | EXOFS_ERR("Error reading super_block stats => %d\n", ret); | 280 | EXOFS_ERR("Error reading super_block stats => %d\n", ret); |
| 243 | goto out; | 281 | goto out; |
| @@ -264,13 +302,13 @@ static int __sbi_read_stats(struct exofs_sb_info *sbi) | |||
| 264 | } | 302 | } |
| 265 | 303 | ||
| 266 | out: | 304 | out: |
| 267 | exofs_put_io_state(ios); | 305 | ore_put_io_state(ios); |
| 268 | return ret; | 306 | return ret; |
| 269 | } | 307 | } |
| 270 | 308 | ||
| 271 | static void stats_done(struct exofs_io_state *ios, void *p) | 309 | static void stats_done(struct ore_io_state *ios, void *p) |
| 272 | { | 310 | { |
| 273 | exofs_put_io_state(ios); | 311 | ore_put_io_state(ios); |
| 274 | /* Good thanks nothing to do anymore */ | 312 | /* Good thanks nothing to do anymore */ |
| 275 | } | 313 | } |
| 276 | 314 | ||
| @@ -280,12 +318,12 @@ int exofs_sbi_write_stats(struct exofs_sb_info *sbi) | |||
| 280 | struct osd_attr attrs[] = { | 318 | struct osd_attr attrs[] = { |
| 281 | [0] = g_attr_sb_stats, | 319 | [0] = g_attr_sb_stats, |
| 282 | }; | 320 | }; |
| 283 | struct exofs_io_state *ios; | 321 | struct ore_io_state *ios; |
| 284 | int ret; | 322 | int ret; |
| 285 | 323 | ||
| 286 | ret = exofs_get_io_state(&sbi->layout, &ios); | 324 | ret = ore_get_io_state(&sbi->layout, &sbi->comps, &ios); |
| 287 | if (unlikely(ret)) { | 325 | if (unlikely(ret)) { |
| 288 | EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__); | 326 | EXOFS_ERR("%s: ore_get_io_state failed.\n", __func__); |
| 289 | return ret; | 327 | return ret; |
| 290 | } | 328 | } |
| 291 | 329 | ||
| @@ -293,21 +331,27 @@ int exofs_sbi_write_stats(struct exofs_sb_info *sbi) | |||
| 293 | sbi->s_ess.s_numfiles = cpu_to_le64(sbi->s_numfiles); | 331 | sbi->s_ess.s_numfiles = cpu_to_le64(sbi->s_numfiles); |
| 294 | attrs[0].val_ptr = &sbi->s_ess; | 332 | attrs[0].val_ptr = &sbi->s_ess; |
| 295 | 333 | ||
| 296 | ios->cred = sbi->s_cred; | 334 | |
| 297 | ios->done = stats_done; | 335 | ios->done = stats_done; |
| 298 | ios->private = sbi; | 336 | ios->private = sbi; |
| 299 | ios->out_attr = attrs; | 337 | ios->out_attr = attrs; |
| 300 | ios->out_attr_len = ARRAY_SIZE(attrs); | 338 | ios->out_attr_len = ARRAY_SIZE(attrs); |
| 301 | 339 | ||
| 302 | ret = exofs_sbi_write(ios); | 340 | ret = ore_write(ios); |
| 303 | if (unlikely(ret)) { | 341 | if (unlikely(ret)) { |
| 304 | EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__); | 342 | EXOFS_ERR("%s: ore_write failed.\n", __func__); |
| 305 | exofs_put_io_state(ios); | 343 | ore_put_io_state(ios); |
| 306 | } | 344 | } |
| 307 | 345 | ||
| 308 | return ret; | 346 | return ret; |
| 309 | } | 347 | } |
| 310 | 348 | ||
| 349 | /****************************************************************************** | ||
| 350 | * SUPERBLOCK FUNCTIONS | ||
| 351 | *****************************************************************************/ | ||
| 352 | static const struct super_operations exofs_sops; | ||
| 353 | static const struct export_operations exofs_export_ops; | ||
| 354 | |||
| 311 | /* | 355 | /* |
| 312 | * Write the superblock to the OSD | 356 | * Write the superblock to the OSD |
| 313 | */ | 357 | */ |
| @@ -315,7 +359,9 @@ int exofs_sync_fs(struct super_block *sb, int wait) | |||
| 315 | { | 359 | { |
| 316 | struct exofs_sb_info *sbi; | 360 | struct exofs_sb_info *sbi; |
| 317 | struct exofs_fscb *fscb; | 361 | struct exofs_fscb *fscb; |
| 318 | struct exofs_io_state *ios; | 362 | struct ore_comp one_comp; |
| 363 | struct ore_components comps; | ||
| 364 | struct ore_io_state *ios; | ||
| 319 | int ret = -ENOMEM; | 365 | int ret = -ENOMEM; |
| 320 | 366 | ||
| 321 | fscb = kmalloc(sizeof(*fscb), GFP_KERNEL); | 367 | fscb = kmalloc(sizeof(*fscb), GFP_KERNEL); |
| @@ -331,7 +377,10 @@ int exofs_sync_fs(struct super_block *sb, int wait) | |||
| 331 | * version). Otherwise the exofs_fscb is read-only from mkfs time. All | 377 | * version). Otherwise the exofs_fscb is read-only from mkfs time. All |
| 332 | * the writeable info is set in exofs_sbi_write_stats() above. | 378 | * the writeable info is set in exofs_sbi_write_stats() above. |
| 333 | */ | 379 | */ |
| 334 | ret = exofs_get_io_state(&sbi->layout, &ios); | 380 | |
| 381 | exofs_init_comps(&comps, &one_comp, sbi, EXOFS_SUPER_ID); | ||
| 382 | |||
| 383 | ret = ore_get_io_state(&sbi->layout, &comps, &ios); | ||
| 335 | if (unlikely(ret)) | 384 | if (unlikely(ret)) |
| 336 | goto out; | 385 | goto out; |
| 337 | 386 | ||
| @@ -345,14 +394,12 @@ int exofs_sync_fs(struct super_block *sb, int wait) | |||
| 345 | fscb->s_newfs = 0; | 394 | fscb->s_newfs = 0; |
| 346 | fscb->s_version = EXOFS_FSCB_VER; | 395 | fscb->s_version = EXOFS_FSCB_VER; |
| 347 | 396 | ||
| 348 | ios->obj.id = EXOFS_SUPER_ID; | ||
| 349 | ios->offset = 0; | 397 | ios->offset = 0; |
| 350 | ios->kern_buff = fscb; | 398 | ios->kern_buff = fscb; |
| 351 | ios->cred = sbi->s_cred; | ||
| 352 | 399 | ||
| 353 | ret = exofs_sbi_write(ios); | 400 | ret = ore_write(ios); |
| 354 | if (unlikely(ret)) | 401 | if (unlikely(ret)) |
| 355 | EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__); | 402 | EXOFS_ERR("%s: ore_write failed.\n", __func__); |
| 356 | else | 403 | else |
| 357 | sb->s_dirt = 0; | 404 | sb->s_dirt = 0; |
| 358 | 405 | ||
| @@ -360,7 +407,7 @@ int exofs_sync_fs(struct super_block *sb, int wait) | |||
| 360 | unlock_super(sb); | 407 | unlock_super(sb); |
| 361 | out: | 408 | out: |
| 362 | EXOFS_DBGMSG("s_nextid=0x%llx ret=%d\n", _LLU(sbi->s_nextid), ret); | 409 | EXOFS_DBGMSG("s_nextid=0x%llx ret=%d\n", _LLU(sbi->s_nextid), ret); |
| 363 | exofs_put_io_state(ios); | 410 | ore_put_io_state(ios); |
| 364 | kfree(fscb); | 411 | kfree(fscb); |
| 365 | return ret; | 412 | return ret; |
| 366 | } | 413 | } |
| @@ -384,15 +431,17 @@ static void _exofs_print_device(const char *msg, const char *dev_path, | |||
| 384 | 431 | ||
| 385 | void exofs_free_sbi(struct exofs_sb_info *sbi) | 432 | void exofs_free_sbi(struct exofs_sb_info *sbi) |
| 386 | { | 433 | { |
| 387 | while (sbi->layout.s_numdevs) { | 434 | while (sbi->comps.numdevs) { |
| 388 | int i = --sbi->layout.s_numdevs; | 435 | int i = --sbi->comps.numdevs; |
| 389 | struct osd_dev *od = sbi->layout.s_ods[i]; | 436 | struct osd_dev *od = sbi->comps.ods[i]; |
| 390 | 437 | ||
| 391 | if (od) { | 438 | if (od) { |
| 392 | sbi->layout.s_ods[i] = NULL; | 439 | sbi->comps.ods[i] = NULL; |
| 393 | osduld_put_device(od); | 440 | osduld_put_device(od); |
| 394 | } | 441 | } |
| 395 | } | 442 | } |
| 443 | if (sbi->comps.ods != sbi->_min_one_dev) | ||
| 444 | kfree(sbi->comps.ods); | ||
| 396 | kfree(sbi); | 445 | kfree(sbi); |
| 397 | } | 446 | } |
| 398 | 447 | ||
| @@ -419,8 +468,8 @@ static void exofs_put_super(struct super_block *sb) | |||
| 419 | msecs_to_jiffies(100)); | 468 | msecs_to_jiffies(100)); |
| 420 | } | 469 | } |
| 421 | 470 | ||
| 422 | _exofs_print_device("Unmounting", NULL, sbi->layout.s_ods[0], | 471 | _exofs_print_device("Unmounting", NULL, sbi->comps.ods[0], |
| 423 | sbi->layout.s_pid); | 472 | sbi->one_comp.obj.partition); |
| 424 | 473 | ||
| 425 | bdi_destroy(&sbi->bdi); | 474 | bdi_destroy(&sbi->bdi); |
| 426 | exofs_free_sbi(sbi); | 475 | exofs_free_sbi(sbi); |
| @@ -501,10 +550,19 @@ static int _read_and_match_data_map(struct exofs_sb_info *sbi, unsigned numdevs, | |||
| 501 | return -EINVAL; | 550 | return -EINVAL; |
| 502 | } | 551 | } |
| 503 | 552 | ||
| 553 | EXOFS_DBGMSG("exofs: layout: " | ||
| 554 | "num_comps=%u stripe_unit=0x%x group_width=%u " | ||
| 555 | "group_depth=0x%llx mirrors_p1=%u raid_algorithm=%u\n", | ||
| 556 | numdevs, | ||
| 557 | sbi->layout.stripe_unit, | ||
| 558 | sbi->layout.group_width, | ||
| 559 | _LLU(sbi->layout.group_depth), | ||
| 560 | sbi->layout.mirrors_p1, | ||
| 561 | sbi->data_map.odm_raid_algorithm); | ||
| 504 | return 0; | 562 | return 0; |
| 505 | } | 563 | } |
| 506 | 564 | ||
| 507 | static unsigned __ra_pages(struct exofs_layout *layout) | 565 | static unsigned __ra_pages(struct ore_layout *layout) |
| 508 | { | 566 | { |
| 509 | const unsigned _MIN_RA = 32; /* min 128K read-ahead */ | 567 | const unsigned _MIN_RA = 32; /* min 128K read-ahead */ |
| 510 | unsigned ra_pages = layout->group_width * layout->stripe_unit / | 568 | unsigned ra_pages = layout->group_width * layout->stripe_unit / |
| @@ -547,13 +605,11 @@ static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev, | |||
| 547 | return !(odi->systemid_len || odi->osdname_len); | 605 | return !(odi->systemid_len || odi->osdname_len); |
| 548 | } | 606 | } |
| 549 | 607 | ||
| 550 | static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi, | 608 | static int exofs_read_lookup_dev_table(struct exofs_sb_info *sbi, |
| 609 | struct osd_dev *fscb_od, | ||
| 551 | unsigned table_count) | 610 | unsigned table_count) |
| 552 | { | 611 | { |
| 553 | struct exofs_sb_info *sbi = *psbi; | 612 | struct ore_comp comp; |
| 554 | struct osd_dev *fscb_od; | ||
| 555 | struct osd_obj_id obj = {.partition = sbi->layout.s_pid, | ||
| 556 | .id = EXOFS_DEVTABLE_ID}; | ||
| 557 | struct exofs_device_table *dt; | 613 | struct exofs_device_table *dt; |
| 558 | unsigned table_bytes = table_count * sizeof(dt->dt_dev_table[0]) + | 614 | unsigned table_bytes = table_count * sizeof(dt->dt_dev_table[0]) + |
| 559 | sizeof(*dt); | 615 | sizeof(*dt); |
| @@ -567,10 +623,14 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi, | |||
| 567 | return -ENOMEM; | 623 | return -ENOMEM; |
| 568 | } | 624 | } |
| 569 | 625 | ||
| 570 | fscb_od = sbi->layout.s_ods[0]; | 626 | sbi->comps.numdevs = 0; |
| 571 | sbi->layout.s_ods[0] = NULL; | 627 | |
| 572 | sbi->layout.s_numdevs = 0; | 628 | comp.obj.partition = sbi->one_comp.obj.partition; |
| 573 | ret = exofs_read_kern(fscb_od, sbi->s_cred, &obj, 0, dt, table_bytes); | 629 | comp.obj.id = EXOFS_DEVTABLE_ID; |
| 630 | exofs_make_credential(comp.cred, &comp.obj); | ||
| 631 | |||
| 632 | ret = exofs_read_kern(fscb_od, comp.cred, &comp.obj, 0, dt, | ||
| 633 | table_bytes); | ||
| 574 | if (unlikely(ret)) { | 634 | if (unlikely(ret)) { |
| 575 | EXOFS_ERR("ERROR: reading device table\n"); | 635 | EXOFS_ERR("ERROR: reading device table\n"); |
| 576 | goto out; | 636 | goto out; |
| @@ -588,16 +648,18 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi, | |||
| 588 | goto out; | 648 | goto out; |
| 589 | 649 | ||
| 590 | if (likely(numdevs > 1)) { | 650 | if (likely(numdevs > 1)) { |
| 591 | unsigned size = numdevs * sizeof(sbi->layout.s_ods[0]); | 651 | unsigned size = numdevs * sizeof(sbi->comps.ods[0]); |
| 592 | 652 | ||
| 593 | sbi = krealloc(sbi, sizeof(*sbi) + size, GFP_KERNEL); | 653 | /* Twice bigger table: See exofs_init_comps() and below |
| 594 | if (unlikely(!sbi)) { | 654 | * comment |
| 655 | */ | ||
| 656 | sbi->comps.ods = kzalloc(size + size - 1, GFP_KERNEL); | ||
| 657 | if (unlikely(!sbi->comps.ods)) { | ||
| 658 | EXOFS_ERR("ERROR: faild allocating Device array[%d]\n", | ||
| 659 | numdevs); | ||
| 595 | ret = -ENOMEM; | 660 | ret = -ENOMEM; |
| 596 | goto out; | 661 | goto out; |
| 597 | } | 662 | } |
| 598 | memset(&sbi->layout.s_ods[1], 0, | ||
| 599 | size - sizeof(sbi->layout.s_ods[0])); | ||
| 600 | *psbi = sbi; | ||
| 601 | } | 663 | } |
| 602 | 664 | ||
| 603 | for (i = 0; i < numdevs; i++) { | 665 | for (i = 0; i < numdevs; i++) { |
| @@ -619,8 +681,8 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi, | |||
| 619 | * line. We always keep them in device-table order. | 681 | * line. We always keep them in device-table order. |
| 620 | */ | 682 | */ |
| 621 | if (fscb_od && osduld_device_same(fscb_od, &odi)) { | 683 | if (fscb_od && osduld_device_same(fscb_od, &odi)) { |
| 622 | sbi->layout.s_ods[i] = fscb_od; | 684 | sbi->comps.ods[i] = fscb_od; |
| 623 | ++sbi->layout.s_numdevs; | 685 | ++sbi->comps.numdevs; |
| 624 | fscb_od = NULL; | 686 | fscb_od = NULL; |
| 625 | continue; | 687 | continue; |
| 626 | } | 688 | } |
| @@ -633,13 +695,13 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi, | |||
| 633 | goto out; | 695 | goto out; |
| 634 | } | 696 | } |
| 635 | 697 | ||
| 636 | sbi->layout.s_ods[i] = od; | 698 | sbi->comps.ods[i] = od; |
| 637 | ++sbi->layout.s_numdevs; | 699 | ++sbi->comps.numdevs; |
| 638 | 700 | ||
| 639 | /* Read the fscb of the other devices to make sure the FS | 701 | /* Read the fscb of the other devices to make sure the FS |
| 640 | * partition is there. | 702 | * partition is there. |
| 641 | */ | 703 | */ |
| 642 | ret = exofs_read_kern(od, sbi->s_cred, &obj, 0, &fscb, | 704 | ret = exofs_read_kern(od, comp.cred, &comp.obj, 0, &fscb, |
| 643 | sizeof(fscb)); | 705 | sizeof(fscb)); |
| 644 | if (unlikely(ret)) { | 706 | if (unlikely(ret)) { |
| 645 | EXOFS_ERR("ERROR: Malformed participating device " | 707 | EXOFS_ERR("ERROR: Malformed participating device " |
| @@ -656,13 +718,22 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi, | |||
| 656 | 718 | ||
| 657 | out: | 719 | out: |
| 658 | kfree(dt); | 720 | kfree(dt); |
| 659 | if (unlikely(!ret && fscb_od)) { | 721 | if (likely(!ret)) { |
| 660 | EXOFS_ERR( | 722 | unsigned numdevs = sbi->comps.numdevs; |
| 661 | "ERROR: Bad device-table container device not present\n"); | ||
| 662 | osduld_put_device(fscb_od); | ||
| 663 | ret = -EINVAL; | ||
| 664 | } | ||
| 665 | 723 | ||
| 724 | if (unlikely(fscb_od)) { | ||
| 725 | EXOFS_ERR("ERROR: Bad device-table container device not present\n"); | ||
| 726 | osduld_put_device(fscb_od); | ||
| 727 | return -EINVAL; | ||
| 728 | } | ||
| 729 | /* exofs round-robins the device table view according to inode | ||
| 730 | * number. We hold a: twice bigger table hence inodes can point | ||
| 731 | * to any device and have a sequential view of the table | ||
| 732 | * starting at this device. See exofs_init_comps() | ||
| 733 | */ | ||
| 734 | for (i = 0; i < numdevs - 1; ++i) | ||
| 735 | sbi->comps.ods[i + numdevs] = sbi->comps.ods[i]; | ||
| 736 | } | ||
| 666 | return ret; | 737 | return ret; |
| 667 | } | 738 | } |
| 668 | 739 | ||
| @@ -676,7 +747,7 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 676 | struct exofs_sb_info *sbi; /*extended info */ | 747 | struct exofs_sb_info *sbi; /*extended info */ |
| 677 | struct osd_dev *od; /* Master device */ | 748 | struct osd_dev *od; /* Master device */ |
| 678 | struct exofs_fscb fscb; /*on-disk superblock info */ | 749 | struct exofs_fscb fscb; /*on-disk superblock info */ |
| 679 | struct osd_obj_id obj; | 750 | struct ore_comp comp; |
| 680 | unsigned table_count; | 751 | unsigned table_count; |
| 681 | int ret; | 752 | int ret; |
| 682 | 753 | ||
| @@ -684,10 +755,6 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 684 | if (!sbi) | 755 | if (!sbi) |
| 685 | return -ENOMEM; | 756 | return -ENOMEM; |
| 686 | 757 | ||
| 687 | ret = bdi_setup_and_register(&sbi->bdi, "exofs", BDI_CAP_MAP_COPY); | ||
| 688 | if (ret) | ||
| 689 | goto free_bdi; | ||
| 690 | |||
| 691 | /* use mount options to fill superblock */ | 758 | /* use mount options to fill superblock */ |
| 692 | if (opts->is_osdname) { | 759 | if (opts->is_osdname) { |
| 693 | struct osd_dev_info odi = {.systemid_len = 0}; | 760 | struct osd_dev_info odi = {.systemid_len = 0}; |
| @@ -695,6 +762,8 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 695 | odi.osdname_len = strlen(opts->dev_name); | 762 | odi.osdname_len = strlen(opts->dev_name); |
| 696 | odi.osdname = (u8 *)opts->dev_name; | 763 | odi.osdname = (u8 *)opts->dev_name; |
| 697 | od = osduld_info_lookup(&odi); | 764 | od = osduld_info_lookup(&odi); |
| 765 | kfree(opts->dev_name); | ||
| 766 | opts->dev_name = NULL; | ||
| 698 | } else { | 767 | } else { |
| 699 | od = osduld_path_lookup(opts->dev_name); | 768 | od = osduld_path_lookup(opts->dev_name); |
| 700 | } | 769 | } |
| @@ -709,11 +778,16 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 709 | sbi->layout.group_width = 1; | 778 | sbi->layout.group_width = 1; |
| 710 | sbi->layout.group_depth = -1; | 779 | sbi->layout.group_depth = -1; |
| 711 | sbi->layout.group_count = 1; | 780 | sbi->layout.group_count = 1; |
| 712 | sbi->layout.s_ods[0] = od; | ||
| 713 | sbi->layout.s_numdevs = 1; | ||
| 714 | sbi->layout.s_pid = opts->pid; | ||
| 715 | sbi->s_timeout = opts->timeout; | 781 | sbi->s_timeout = opts->timeout; |
| 716 | 782 | ||
| 783 | sbi->one_comp.obj.partition = opts->pid; | ||
| 784 | sbi->one_comp.obj.id = 0; | ||
| 785 | exofs_make_credential(sbi->one_comp.cred, &sbi->one_comp.obj); | ||
| 786 | sbi->comps.numdevs = 1; | ||
| 787 | sbi->comps.single_comp = EC_SINGLE_COMP; | ||
| 788 | sbi->comps.comps = &sbi->one_comp; | ||
| 789 | sbi->comps.ods = sbi->_min_one_dev; | ||
| 790 | |||
| 717 | /* fill in some other data by hand */ | 791 | /* fill in some other data by hand */ |
| 718 | memset(sb->s_id, 0, sizeof(sb->s_id)); | 792 | memset(sb->s_id, 0, sizeof(sb->s_id)); |
| 719 | strcpy(sb->s_id, "exofs"); | 793 | strcpy(sb->s_id, "exofs"); |
| @@ -724,11 +798,11 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 724 | sb->s_bdev = NULL; | 798 | sb->s_bdev = NULL; |
| 725 | sb->s_dev = 0; | 799 | sb->s_dev = 0; |
| 726 | 800 | ||
| 727 | obj.partition = sbi->layout.s_pid; | 801 | comp.obj.partition = sbi->one_comp.obj.partition; |
| 728 | obj.id = EXOFS_SUPER_ID; | 802 | comp.obj.id = EXOFS_SUPER_ID; |
| 729 | exofs_make_credential(sbi->s_cred, &obj); | 803 | exofs_make_credential(comp.cred, &comp.obj); |
| 730 | 804 | ||
| 731 | ret = exofs_read_kern(od, sbi->s_cred, &obj, 0, &fscb, sizeof(fscb)); | 805 | ret = exofs_read_kern(od, comp.cred, &comp.obj, 0, &fscb, sizeof(fscb)); |
| 732 | if (unlikely(ret)) | 806 | if (unlikely(ret)) |
| 733 | goto free_sbi; | 807 | goto free_sbi; |
| 734 | 808 | ||
| @@ -757,9 +831,11 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 757 | 831 | ||
| 758 | table_count = le64_to_cpu(fscb.s_dev_table_count); | 832 | table_count = le64_to_cpu(fscb.s_dev_table_count); |
| 759 | if (table_count) { | 833 | if (table_count) { |
| 760 | ret = exofs_read_lookup_dev_table(&sbi, table_count); | 834 | ret = exofs_read_lookup_dev_table(sbi, od, table_count); |
| 761 | if (unlikely(ret)) | 835 | if (unlikely(ret)) |
| 762 | goto free_sbi; | 836 | goto free_sbi; |
| 837 | } else { | ||
| 838 | sbi->comps.ods[0] = od; | ||
| 763 | } | 839 | } |
| 764 | 840 | ||
| 765 | __sbi_read_stats(sbi); | 841 | __sbi_read_stats(sbi); |
| @@ -793,20 +869,20 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 793 | goto free_sbi; | 869 | goto free_sbi; |
| 794 | } | 870 | } |
| 795 | 871 | ||
| 796 | _exofs_print_device("Mounting", opts->dev_name, sbi->layout.s_ods[0], | 872 | ret = bdi_setup_and_register(&sbi->bdi, "exofs", BDI_CAP_MAP_COPY); |
| 797 | sbi->layout.s_pid); | 873 | if (ret) { |
| 798 | if (opts->is_osdname) | 874 | EXOFS_DBGMSG("Failed to bdi_setup_and_register\n"); |
| 799 | kfree(opts->dev_name); | 875 | goto free_sbi; |
| 876 | } | ||
| 877 | |||
| 878 | _exofs_print_device("Mounting", opts->dev_name, sbi->comps.ods[0], | ||
| 879 | sbi->one_comp.obj.partition); | ||
| 800 | return 0; | 880 | return 0; |
| 801 | 881 | ||
| 802 | free_sbi: | 882 | free_sbi: |
| 803 | bdi_destroy(&sbi->bdi); | ||
| 804 | free_bdi: | ||
| 805 | EXOFS_ERR("Unable to mount exofs on %s pid=0x%llx err=%d\n", | 883 | EXOFS_ERR("Unable to mount exofs on %s pid=0x%llx err=%d\n", |
| 806 | opts->dev_name, sbi->layout.s_pid, ret); | 884 | opts->dev_name, sbi->one_comp.obj.partition, ret); |
| 807 | exofs_free_sbi(sbi); | 885 | exofs_free_sbi(sbi); |
| 808 | if (opts->is_osdname) | ||
| 809 | kfree(opts->dev_name); | ||
| 810 | return ret; | 886 | return ret; |
| 811 | } | 887 | } |
| 812 | 888 | ||
| @@ -837,7 +913,7 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 837 | { | 913 | { |
| 838 | struct super_block *sb = dentry->d_sb; | 914 | struct super_block *sb = dentry->d_sb; |
| 839 | struct exofs_sb_info *sbi = sb->s_fs_info; | 915 | struct exofs_sb_info *sbi = sb->s_fs_info; |
| 840 | struct exofs_io_state *ios; | 916 | struct ore_io_state *ios; |
| 841 | struct osd_attr attrs[] = { | 917 | struct osd_attr attrs[] = { |
| 842 | ATTR_DEF(OSD_APAGE_PARTITION_QUOTAS, | 918 | ATTR_DEF(OSD_APAGE_PARTITION_QUOTAS, |
| 843 | OSD_ATTR_PQ_CAPACITY_QUOTA, sizeof(__be64)), | 919 | OSD_ATTR_PQ_CAPACITY_QUOTA, sizeof(__be64)), |
| @@ -846,21 +922,18 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 846 | }; | 922 | }; |
| 847 | uint64_t capacity = ULLONG_MAX; | 923 | uint64_t capacity = ULLONG_MAX; |
| 848 | uint64_t used = ULLONG_MAX; | 924 | uint64_t used = ULLONG_MAX; |
| 849 | uint8_t cred_a[OSD_CAP_LEN]; | ||
| 850 | int ret; | 925 | int ret; |
| 851 | 926 | ||
| 852 | ret = exofs_get_io_state(&sbi->layout, &ios); | 927 | ret = ore_get_io_state(&sbi->layout, &sbi->comps, &ios); |
| 853 | if (ret) { | 928 | if (ret) { |
| 854 | EXOFS_DBGMSG("exofs_get_io_state failed.\n"); | 929 | EXOFS_DBGMSG("ore_get_io_state failed.\n"); |
| 855 | return ret; | 930 | return ret; |
| 856 | } | 931 | } |
| 857 | 932 | ||
| 858 | exofs_make_credential(cred_a, &ios->obj); | ||
| 859 | ios->cred = sbi->s_cred; | ||
| 860 | ios->in_attr = attrs; | 933 | ios->in_attr = attrs; |
| 861 | ios->in_attr_len = ARRAY_SIZE(attrs); | 934 | ios->in_attr_len = ARRAY_SIZE(attrs); |
| 862 | 935 | ||
| 863 | ret = exofs_sbi_read(ios); | 936 | ret = ore_read(ios); |
| 864 | if (unlikely(ret)) | 937 | if (unlikely(ret)) |
| 865 | goto out; | 938 | goto out; |
| 866 | 939 | ||
| @@ -889,7 +962,7 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 889 | buf->f_namelen = EXOFS_NAME_LEN; | 962 | buf->f_namelen = EXOFS_NAME_LEN; |
| 890 | 963 | ||
| 891 | out: | 964 | out: |
| 892 | exofs_put_io_state(ios); | 965 | ore_put_io_state(ios); |
| 893 | return ret; | 966 | return ret; |
| 894 | } | 967 | } |
| 895 | 968 | ||
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 569ea5b76fda..abd615d74a29 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
| @@ -773,6 +773,11 @@ struct nfs3_getaclres { | |||
| 773 | struct posix_acl * acl_default; | 773 | struct posix_acl * acl_default; |
| 774 | }; | 774 | }; |
| 775 | 775 | ||
| 776 | struct nfs4_string { | ||
| 777 | unsigned int len; | ||
| 778 | char *data; | ||
| 779 | }; | ||
| 780 | |||
| 776 | #ifdef CONFIG_NFS_V4 | 781 | #ifdef CONFIG_NFS_V4 |
| 777 | 782 | ||
| 778 | typedef u64 clientid4; | 783 | typedef u64 clientid4; |
| @@ -963,11 +968,6 @@ struct nfs4_server_caps_res { | |||
| 963 | struct nfs4_sequence_res seq_res; | 968 | struct nfs4_sequence_res seq_res; |
| 964 | }; | 969 | }; |
| 965 | 970 | ||
| 966 | struct nfs4_string { | ||
| 967 | unsigned int len; | ||
| 968 | char *data; | ||
| 969 | }; | ||
| 970 | |||
| 971 | #define NFS4_PATHNAME_MAXCOMPONENTS 512 | 971 | #define NFS4_PATHNAME_MAXCOMPONENTS 512 |
| 972 | struct nfs4_pathname { | 972 | struct nfs4_pathname { |
| 973 | unsigned int ncomponents; | 973 | unsigned int ncomponents; |
diff --git a/include/scsi/osd_ore.h b/include/scsi/osd_ore.h new file mode 100644 index 000000000000..c5c5e008e6de --- /dev/null +++ b/include/scsi/osd_ore.h | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2011 | ||
| 3 | * Boaz Harrosh <bharrosh@panasas.com> | ||
| 4 | * | ||
| 5 | * Public Declarations of the ORE API | ||
| 6 | * | ||
| 7 | * This file is part of the ORE (Object Raid Engine) library. | ||
| 8 | * | ||
| 9 | * ORE is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License version 2 as published | ||
| 11 | * by the Free Software Foundation. (GPL v2) | ||
| 12 | * | ||
| 13 | * ORE is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License | ||
| 19 | * along with the ORE; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | */ | ||
| 22 | #ifndef __ORE_H__ | ||
| 23 | #define __ORE_H__ | ||
| 24 | |||
| 25 | #include <scsi/osd_initiator.h> | ||
| 26 | #include <scsi/osd_attributes.h> | ||
| 27 | #include <scsi/osd_sec.h> | ||
| 28 | #include <linux/pnfs_osd_xdr.h> | ||
| 29 | |||
| 30 | struct ore_comp { | ||
| 31 | struct osd_obj_id obj; | ||
| 32 | u8 cred[OSD_CAP_LEN]; | ||
| 33 | }; | ||
| 34 | |||
| 35 | struct ore_layout { | ||
| 36 | /* Our way of looking at the data_map */ | ||
| 37 | unsigned stripe_unit; | ||
| 38 | unsigned mirrors_p1; | ||
| 39 | |||
| 40 | unsigned group_width; | ||
| 41 | u64 group_depth; | ||
| 42 | unsigned group_count; | ||
| 43 | }; | ||
| 44 | |||
| 45 | struct ore_components { | ||
| 46 | unsigned numdevs; /* Num of devices in array */ | ||
| 47 | /* If @single_comp == EC_SINGLE_COMP, @comps points to a single | ||
| 48 | * component. else there are @numdevs components | ||
| 49 | */ | ||
| 50 | enum EC_COMP_USAGE { | ||
| 51 | EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff | ||
| 52 | } single_comp; | ||
| 53 | struct ore_comp *comps; | ||
| 54 | struct osd_dev **ods; /* osd_dev array */ | ||
| 55 | }; | ||
| 56 | |||
| 57 | struct ore_io_state; | ||
| 58 | typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private); | ||
| 59 | |||
| 60 | struct ore_io_state { | ||
| 61 | struct kref kref; | ||
| 62 | |||
| 63 | void *private; | ||
| 64 | ore_io_done_fn done; | ||
| 65 | |||
| 66 | struct ore_layout *layout; | ||
| 67 | struct ore_components *comps; | ||
| 68 | |||
| 69 | /* Global read/write IO*/ | ||
| 70 | loff_t offset; | ||
| 71 | unsigned long length; | ||
| 72 | void *kern_buff; | ||
| 73 | |||
| 74 | struct page **pages; | ||
| 75 | unsigned nr_pages; | ||
| 76 | unsigned pgbase; | ||
| 77 | unsigned pages_consumed; | ||
| 78 | |||
| 79 | /* Attributes */ | ||
| 80 | unsigned in_attr_len; | ||
| 81 | struct osd_attr *in_attr; | ||
| 82 | unsigned out_attr_len; | ||
| 83 | struct osd_attr *out_attr; | ||
| 84 | |||
| 85 | bool reading; | ||
| 86 | |||
| 87 | /* Variable array of size numdevs */ | ||
| 88 | unsigned numdevs; | ||
| 89 | struct ore_per_dev_state { | ||
| 90 | struct osd_request *or; | ||
| 91 | struct bio *bio; | ||
| 92 | loff_t offset; | ||
| 93 | unsigned length; | ||
| 94 | unsigned dev; | ||
| 95 | } per_dev[]; | ||
| 96 | }; | ||
| 97 | |||
| 98 | static inline unsigned ore_io_state_size(unsigned numdevs) | ||
| 99 | { | ||
| 100 | return sizeof(struct ore_io_state) + | ||
| 101 | sizeof(struct ore_per_dev_state) * numdevs; | ||
| 102 | } | ||
| 103 | |||
| 104 | /* ore.c */ | ||
| 105 | int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps, | ||
| 106 | bool is_reading, u64 offset, u64 length, | ||
| 107 | struct ore_io_state **ios); | ||
| 108 | int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps, | ||
| 109 | struct ore_io_state **ios); | ||
| 110 | void ore_put_io_state(struct ore_io_state *ios); | ||
| 111 | |||
| 112 | int ore_check_io(struct ore_io_state *ios, u64 *resid); | ||
| 113 | |||
| 114 | int ore_create(struct ore_io_state *ios); | ||
| 115 | int ore_remove(struct ore_io_state *ios); | ||
| 116 | int ore_write(struct ore_io_state *ios); | ||
| 117 | int ore_read(struct ore_io_state *ios); | ||
| 118 | int ore_truncate(struct ore_layout *layout, struct ore_components *comps, | ||
| 119 | u64 size); | ||
| 120 | |||
| 121 | int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr); | ||
| 122 | |||
| 123 | extern const struct osd_attr g_attr_logical_length; | ||
| 124 | |||
| 125 | #endif | ||
