diff options
| -rw-r--r-- | fs/gfs2/xattr.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index 3e96dce21c1c..05de20954659 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c | |||
| @@ -610,7 +610,6 @@ static int gfs2_xattr_get(const struct xattr_handler *handler, | |||
| 610 | { | 610 | { |
| 611 | struct gfs2_inode *ip = GFS2_I(inode); | 611 | struct gfs2_inode *ip = GFS2_I(inode); |
| 612 | struct gfs2_holder gh; | 612 | struct gfs2_holder gh; |
| 613 | bool need_unlock = false; | ||
| 614 | int ret; | 613 | int ret; |
| 615 | 614 | ||
| 616 | /* During lookup, SELinux calls this function with the glock locked. */ | 615 | /* During lookup, SELinux calls this function with the glock locked. */ |
| @@ -619,10 +618,11 @@ static int gfs2_xattr_get(const struct xattr_handler *handler, | |||
| 619 | ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); | 618 | ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); |
| 620 | if (ret) | 619 | if (ret) |
| 621 | return ret; | 620 | return ret; |
| 622 | need_unlock = true; | 621 | } else { |
| 622 | gfs2_holder_mark_uninitialized(&gh); | ||
| 623 | } | 623 | } |
| 624 | ret = __gfs2_xattr_get(inode, name, buffer, size, handler->flags); | 624 | ret = __gfs2_xattr_get(inode, name, buffer, size, handler->flags); |
| 625 | if (need_unlock) | 625 | if (gfs2_holder_initialized(&gh)) |
| 626 | gfs2_glock_dq_uninit(&gh); | 626 | gfs2_glock_dq_uninit(&gh); |
| 627 | return ret; | 627 | return ret; |
| 628 | } | 628 | } |
| @@ -1244,11 +1244,20 @@ static int gfs2_xattr_set(const struct xattr_handler *handler, | |||
| 1244 | if (ret) | 1244 | if (ret) |
| 1245 | return ret; | 1245 | return ret; |
| 1246 | 1246 | ||
| 1247 | ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | 1247 | /* May be called from gfs_setattr with the glock locked. */ |
| 1248 | if (ret) | 1248 | |
| 1249 | return ret; | 1249 | if (!gfs2_glock_is_locked_by_me(ip->i_gl)) { |
| 1250 | ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | ||
| 1251 | if (ret) | ||
| 1252 | return ret; | ||
| 1253 | } else { | ||
| 1254 | if (WARN_ON_ONCE(ip->i_gl->gl_state != LM_ST_EXCLUSIVE)) | ||
| 1255 | return -EIO; | ||
| 1256 | gfs2_holder_mark_uninitialized(&gh); | ||
| 1257 | } | ||
| 1250 | ret = __gfs2_xattr_set(inode, name, value, size, flags, handler->flags); | 1258 | ret = __gfs2_xattr_set(inode, name, value, size, flags, handler->flags); |
| 1251 | gfs2_glock_dq_uninit(&gh); | 1259 | if (gfs2_holder_initialized(&gh)) |
| 1260 | gfs2_glock_dq_uninit(&gh); | ||
| 1252 | return ret; | 1261 | return ret; |
| 1253 | } | 1262 | } |
| 1254 | 1263 | ||
