aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exofs/inode.c
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2010-01-28 04:58:08 -0500
committerBoaz Harrosh <bharrosh@panasas.com>2010-02-28 06:35:28 -0500
commitd9c740d2253e75db8cef8f87a3125c450f3ebd82 (patch)
tree7217cf62b8d102e00257be6e0675d25852045bc6 /fs/exofs/inode.c
parent46f4d973f6874c06b7a41a3bf8f4c1717d90f97a (diff)
exofs: Define on-disk per-inode optional layout attribute
* Layouts describe the way a file is spread on multiple devices. The layout information is stored in the objects attribute introduced in this patch. * There can be multiple generating function for the layout. Currently defined: - No attribute present - use below moving-window on global device table, all devices. (This is the only one currently used in exofs) - an obj_id generated moving window - the obj_id is a randomizing factor in the otherwise global map layout. - An explicit layout stored, including a data_map and a device index list. - More might be defined in future ... * There are two attributes defined of the same structure: A-data-files-layout - This layout is used by data-files. If present at a directory, all files of that directory will be created with this layout. A-meta-data-layout - This layout is used by a directory and other meta-data information. Also inherited at creation of subdirectories. * At creation time inodes are created with the layout specified above. A usermode utility may change the creation layout on a give directory or file. Which in the case of directories, will also apply to newly created files/subdirectories, children of that directory. In the simple unaltered case of a newly created exofs, no layout attributes are present, and all layouts adhere to the layout specified at the device-table. * In case of a future file system loaded in an old exofs-driver. At iget(), the generating_function is inspected and if not supported will return an IO error to the application and the inode will not be loaded. So not to damage any data. Note: After this patch we do not yet support any type of layout only the RAID0 patch that enables striping at the super-block level will add support for RAID0 layouts above. This way we are past and future compatible and fully bisectable. * Access to the device table is done by an accessor since it will change according to above information. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Diffstat (limited to 'fs/exofs/inode.c')
-rw-r--r--fs/exofs/inode.c56
1 files changed, 51 insertions, 5 deletions
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 03189a958b33..0163546ba05a 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -859,6 +859,15 @@ int exofs_setattr(struct dentry *dentry, struct iattr *iattr)
859 return error; 859 return error;
860} 860}
861 861
862static const struct osd_attr g_attr_inode_file_layout = ATTR_DEF(
863 EXOFS_APAGE_FS_DATA,
864 EXOFS_ATTR_INODE_FILE_LAYOUT,
865 0);
866static const struct osd_attr g_attr_inode_dir_layout = ATTR_DEF(
867 EXOFS_APAGE_FS_DATA,
868 EXOFS_ATTR_INODE_DIR_LAYOUT,
869 0);
870
862/* 871/*
863 * Read an inode from the OSD, and return it as is. We also return the size 872 * Read an inode from the OSD, and return it as is. We also return the size
864 * attribute in the 'obj_size' argument. 873 * attribute in the 'obj_size' argument.
@@ -867,11 +876,16 @@ static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi,
867 struct exofs_fcb *inode, uint64_t *obj_size) 876 struct exofs_fcb *inode, uint64_t *obj_size)
868{ 877{
869 struct exofs_sb_info *sbi = sb->s_fs_info; 878 struct exofs_sb_info *sbi = sb->s_fs_info;
870 struct osd_attr attrs[2]; 879 struct osd_attr attrs[] = {
880 [0] = g_attr_inode_data,
881 [1] = g_attr_inode_file_layout,
882 [2] = g_attr_inode_dir_layout,
883 [3] = g_attr_logical_length,
884 };
871 struct exofs_io_state *ios; 885 struct exofs_io_state *ios;
886 struct exofs_on_disk_inode_layout *layout;
872 int ret; 887 int ret;
873 888
874 *obj_size = ~0;
875 ret = exofs_get_io_state(&sbi->layout, &ios); 889 ret = exofs_get_io_state(&sbi->layout, &ios);
876 if (unlikely(ret)) { 890 if (unlikely(ret)) {
877 EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__); 891 EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__);
@@ -882,8 +896,9 @@ static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi,
882 exofs_make_credential(oi->i_cred, &ios->obj); 896 exofs_make_credential(oi->i_cred, &ios->obj);
883 ios->cred = oi->i_cred; 897 ios->cred = oi->i_cred;
884 898
885 attrs[0] = g_attr_inode_data; 899 attrs[1].len = exofs_on_disk_inode_layout_size(sbi->layout.s_numdevs);
886 attrs[1] = g_attr_logical_length; 900 attrs[2].len = exofs_on_disk_inode_layout_size(sbi->layout.s_numdevs);
901
887 ios->in_attr = attrs; 902 ios->in_attr = attrs;
888 ios->in_attr_len = ARRAY_SIZE(attrs); 903 ios->in_attr_len = ARRAY_SIZE(attrs);
889 904
@@ -901,11 +916,42 @@ static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi,
901 916
902 ret = extract_attr_from_ios(ios, &attrs[1]); 917 ret = extract_attr_from_ios(ios, &attrs[1]);
903 if (ret) { 918 if (ret) {
919 EXOFS_ERR("%s: extract_attr of inode_data failed\n", __func__);
920 goto out;
921 }
922 if (attrs[1].len) {
923 layout = attrs[1].val_ptr;
924 if (layout->gen_func != cpu_to_le16(LAYOUT_MOVING_WINDOW)) {
925 EXOFS_ERR("%s: unsupported files layout %d\n",
926 __func__, layout->gen_func);
927 ret = -ENOTSUPP;
928 goto out;
929 }
930 }
931
932 ret = extract_attr_from_ios(ios, &attrs[2]);
933 if (ret) {
934 EXOFS_ERR("%s: extract_attr of inode_data failed\n", __func__);
935 goto out;
936 }
937 if (attrs[2].len) {
938 layout = attrs[2].val_ptr;
939 if (layout->gen_func != cpu_to_le16(LAYOUT_MOVING_WINDOW)) {
940 EXOFS_ERR("%s: unsupported meta-data layout %d\n",
941 __func__, layout->gen_func);
942 ret = -ENOTSUPP;
943 goto out;
944 }
945 }
946
947 *obj_size = ~0;
948 ret = extract_attr_from_ios(ios, &attrs[3]);
949 if (ret) {
904 EXOFS_ERR("%s: extract_attr of logical_length failed\n", 950 EXOFS_ERR("%s: extract_attr of logical_length failed\n",
905 __func__); 951 __func__);
906 goto out; 952 goto out;
907 } 953 }
908 *obj_size = get_unaligned_be64(attrs[1].val_ptr); 954 *obj_size = get_unaligned_be64(attrs[3].val_ptr);
909 955
910out: 956out:
911 exofs_put_io_state(ios); 957 exofs_put_io_state(ios);