orangefs: simplify orangefs_inode_is_stale
Check whether this is a new inode at location of call. Raises the question of what to do with an unknown inode type. Old code would've marked the inode bad and returned ESTALE. Signed-off-by: Martin Brandenburg <martin@omnibond.com> Signed-off-by: Mike Marshall <hubcap@omnibond.com>
This commit is contained in:
parent
cf546ab6b1
commit
480e5ae9b8
@ -249,25 +249,23 @@ static void orangefs_make_bad_inode(struct inode *inode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int orangefs_inode_is_stale(struct inode *inode, int new,
|
static int orangefs_inode_is_stale(struct inode *inode,
|
||||||
struct ORANGEFS_sys_attr_s *attrs, char *link_target)
|
struct ORANGEFS_sys_attr_s *attrs, char *link_target)
|
||||||
{
|
{
|
||||||
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
|
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
|
||||||
int type = orangefs_inode_type(attrs->objtype);
|
int type = orangefs_inode_type(attrs->objtype);
|
||||||
if (!new) {
|
/*
|
||||||
/*
|
* If the inode type or symlink target have changed then this
|
||||||
* If the inode type or symlink target have changed then this
|
* inode is stale.
|
||||||
* inode is stale.
|
*/
|
||||||
*/
|
if (type == -1 || !(inode->i_mode & type)) {
|
||||||
if (type == -1 || !(inode->i_mode & type)) {
|
orangefs_make_bad_inode(inode);
|
||||||
orangefs_make_bad_inode(inode);
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
if (type == S_IFLNK && strncmp(orangefs_inode->link_target,
|
||||||
if (type == S_IFLNK && strncmp(orangefs_inode->link_target,
|
link_target, ORANGEFS_NAME_MAX)) {
|
||||||
link_target, ORANGEFS_NAME_MAX)) {
|
orangefs_make_bad_inode(inode);
|
||||||
orangefs_make_bad_inode(inode);
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -313,16 +311,18 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,
|
|||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
type = orangefs_inode_type(new_op->
|
if (!new) {
|
||||||
downcall.resp.getattr.attributes.objtype);
|
ret = orangefs_inode_is_stale(inode,
|
||||||
ret = orangefs_inode_is_stale(inode, new,
|
&new_op->downcall.resp.getattr.attributes,
|
||||||
&new_op->downcall.resp.getattr.attributes,
|
new_op->downcall.resp.getattr.link_target);
|
||||||
new_op->downcall.resp.getattr.link_target);
|
if (ret) {
|
||||||
if (ret) {
|
ret = -ESTALE;
|
||||||
ret = -ESTALE;
|
goto out;
|
||||||
goto out;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type = orangefs_inode_type(new_op->
|
||||||
|
downcall.resp.getattr.attributes.objtype);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case S_IFREG:
|
case S_IFREG:
|
||||||
inode->i_flags = orangefs_inode_flags(&new_op->
|
inode->i_flags = orangefs_inode_flags(&new_op->
|
||||||
@ -367,6 +367,12 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,
|
|||||||
inode->i_link = orangefs_inode->link_target;
|
inode->i_link = orangefs_inode->link_target;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
/* i.e. -1 */
|
||||||
|
default:
|
||||||
|
/* XXX: ESTALE? This is what is done if it is not new. */
|
||||||
|
orangefs_make_bad_inode(inode);
|
||||||
|
ret = -ESTALE;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
inode->i_uid = make_kuid(&init_user_ns, new_op->
|
inode->i_uid = make_kuid(&init_user_ns, new_op->
|
||||||
@ -420,7 +426,7 @@ int orangefs_inode_check_changed(struct inode *inode)
|
|||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = orangefs_inode_is_stale(inode, 0,
|
ret = orangefs_inode_is_stale(inode,
|
||||||
&new_op->downcall.resp.getattr.attributes,
|
&new_op->downcall.resp.getattr.attributes,
|
||||||
new_op->downcall.resp.getattr.link_target);
|
new_op->downcall.resp.getattr.link_target);
|
||||||
out:
|
out:
|
||||||
|
Loading…
Reference in New Issue
Block a user