diff options
author | Martin Brandenburg <martin@omnibond.com> | 2016-01-25 15:33:39 -0500 |
---|---|---|
committer | Mike Marshall <hubcap@omnibond.com> | 2016-01-28 15:08:39 -0500 |
commit | 394f647e3ad073dab19ba081501e4a0ca05302c4 (patch) | |
tree | 726cf3ab74f14895e8c41bac59bdc245ec7fb84c /fs/orangefs | |
parent | 115b93a8595c878759c7c1fdbd95fbbeacbe9168 (diff) |
orangefs: Util functions shouldn't operate on inode where it can be avoided.
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Diffstat (limited to 'fs/orangefs')
-rw-r--r-- | fs/orangefs/orangefs-utils.c | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c index 92a38b0091f2..035f050ae0e8 100644 --- a/fs/orangefs/orangefs-utils.c +++ b/fs/orangefs/orangefs-utils.c | |||
@@ -78,24 +78,55 @@ __s32 fsid_of_op(struct orangefs_kernel_op_s *op) | |||
78 | return fsid; | 78 | return fsid; |
79 | } | 79 | } |
80 | 80 | ||
81 | static void orangefs_set_inode_flags(struct inode *inode, | 81 | static int orangefs_inode_flags(struct ORANGEFS_sys_attr_s *attrs) |
82 | struct ORANGEFS_sys_attr_s *attrs) | ||
83 | { | 82 | { |
83 | int flags = 0; | ||
84 | if (attrs->flags & ORANGEFS_IMMUTABLE_FL) | 84 | if (attrs->flags & ORANGEFS_IMMUTABLE_FL) |
85 | inode->i_flags |= S_IMMUTABLE; | 85 | flags |= S_IMMUTABLE; |
86 | else | 86 | else |
87 | inode->i_flags &= ~S_IMMUTABLE; | 87 | flags &= ~S_IMMUTABLE; |
88 | |||
89 | if (attrs->flags & ORANGEFS_APPEND_FL) | 88 | if (attrs->flags & ORANGEFS_APPEND_FL) |
90 | inode->i_flags |= S_APPEND; | 89 | flags |= S_APPEND; |
91 | else | 90 | else |
92 | inode->i_flags &= ~S_APPEND; | 91 | flags &= ~S_APPEND; |
93 | |||
94 | if (attrs->flags & ORANGEFS_NOATIME_FL) | 92 | if (attrs->flags & ORANGEFS_NOATIME_FL) |
95 | inode->i_flags |= S_NOATIME; | 93 | flags |= S_NOATIME; |
96 | else | 94 | else |
97 | inode->i_flags &= ~S_NOATIME; | 95 | flags &= ~S_NOATIME; |
96 | return flags; | ||
97 | } | ||
98 | |||
99 | static int orangefs_inode_perms(struct ORANGEFS_sys_attr_s *attrs) | ||
100 | { | ||
101 | int perm_mode = 0; | ||
102 | |||
103 | if (attrs->perms & ORANGEFS_O_EXECUTE) | ||
104 | perm_mode |= S_IXOTH; | ||
105 | if (attrs->perms & ORANGEFS_O_WRITE) | ||
106 | perm_mode |= S_IWOTH; | ||
107 | if (attrs->perms & ORANGEFS_O_READ) | ||
108 | perm_mode |= S_IROTH; | ||
109 | |||
110 | if (attrs->perms & ORANGEFS_G_EXECUTE) | ||
111 | perm_mode |= S_IXGRP; | ||
112 | if (attrs->perms & ORANGEFS_G_WRITE) | ||
113 | perm_mode |= S_IWGRP; | ||
114 | if (attrs->perms & ORANGEFS_G_READ) | ||
115 | perm_mode |= S_IRGRP; | ||
98 | 116 | ||
117 | if (attrs->perms & ORANGEFS_U_EXECUTE) | ||
118 | perm_mode |= S_IXUSR; | ||
119 | if (attrs->perms & ORANGEFS_U_WRITE) | ||
120 | perm_mode |= S_IWUSR; | ||
121 | if (attrs->perms & ORANGEFS_U_READ) | ||
122 | perm_mode |= S_IRUSR; | ||
123 | |||
124 | if (attrs->perms & ORANGEFS_G_SGID) | ||
125 | perm_mode |= S_ISGID; | ||
126 | if (attrs->perms & ORANGEFS_U_SUID) | ||
127 | perm_mode |= S_ISUID; | ||
128 | |||
129 | return perm_mode; | ||
99 | } | 130 | } |
100 | 131 | ||
101 | /* NOTE: symname is ignored unless the inode is a sym link */ | 132 | /* NOTE: symname is ignored unless the inode is a sym link */ |
@@ -104,7 +135,6 @@ static int copy_attributes_to_inode(struct inode *inode, | |||
104 | char *symname) | 135 | char *symname) |
105 | { | 136 | { |
106 | int ret = -1; | 137 | int ret = -1; |
107 | int perm_mode = 0; | ||
108 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); | 138 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); |
109 | loff_t inode_size = 0; | 139 | loff_t inode_size = 0; |
110 | loff_t rounded_up_size = 0; | 140 | loff_t rounded_up_size = 0; |
@@ -134,7 +164,7 @@ static int copy_attributes_to_inode(struct inode *inode, | |||
134 | 164 | ||
135 | switch (attrs->objtype) { | 165 | switch (attrs->objtype) { |
136 | case ORANGEFS_TYPE_METAFILE: | 166 | case ORANGEFS_TYPE_METAFILE: |
137 | orangefs_set_inode_flags(inode, attrs); | 167 | inode->i_flags = orangefs_inode_flags(attrs); |
138 | if (attrs->mask & ORANGEFS_ATTR_SYS_SIZE) { | 168 | if (attrs->mask & ORANGEFS_ATTR_SYS_SIZE) { |
139 | inode_size = (loff_t) attrs->size; | 169 | inode_size = (loff_t) attrs->size; |
140 | rounded_up_size = | 170 | rounded_up_size = |
@@ -179,33 +209,7 @@ static int copy_attributes_to_inode(struct inode *inode, | |||
179 | inode->i_mtime.tv_nsec = 0; | 209 | inode->i_mtime.tv_nsec = 0; |
180 | inode->i_ctime.tv_nsec = 0; | 210 | inode->i_ctime.tv_nsec = 0; |
181 | 211 | ||
182 | if (attrs->perms & ORANGEFS_O_EXECUTE) | 212 | inode->i_mode = orangefs_inode_perms(attrs); |
183 | perm_mode |= S_IXOTH; | ||
184 | if (attrs->perms & ORANGEFS_O_WRITE) | ||
185 | perm_mode |= S_IWOTH; | ||
186 | if (attrs->perms & ORANGEFS_O_READ) | ||
187 | perm_mode |= S_IROTH; | ||
188 | |||
189 | if (attrs->perms & ORANGEFS_G_EXECUTE) | ||
190 | perm_mode |= S_IXGRP; | ||
191 | if (attrs->perms & ORANGEFS_G_WRITE) | ||
192 | perm_mode |= S_IWGRP; | ||
193 | if (attrs->perms & ORANGEFS_G_READ) | ||
194 | perm_mode |= S_IRGRP; | ||
195 | |||
196 | if (attrs->perms & ORANGEFS_U_EXECUTE) | ||
197 | perm_mode |= S_IXUSR; | ||
198 | if (attrs->perms & ORANGEFS_U_WRITE) | ||
199 | perm_mode |= S_IWUSR; | ||
200 | if (attrs->perms & ORANGEFS_U_READ) | ||
201 | perm_mode |= S_IRUSR; | ||
202 | |||
203 | if (attrs->perms & ORANGEFS_G_SGID) | ||
204 | perm_mode |= S_ISGID; | ||
205 | if (attrs->perms & ORANGEFS_U_SUID) | ||
206 | perm_mode |= S_ISUID; | ||
207 | |||
208 | inode->i_mode = perm_mode; | ||
209 | 213 | ||
210 | if (is_root_handle(inode)) { | 214 | if (is_root_handle(inode)) { |
211 | /* special case: mark the root inode as sticky */ | 215 | /* special case: mark the root inode as sticky */ |