Skip to content

Commit a500bd3

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: Allow append and immutable bits to coexist
Before this patch, function do_gfs2_set_flags checked if the append and immutable flags were being set while already set. If so, error -EPERM was given. There's no reason why these two flags should be mutually exclusive, and if you set them separately, you will, in essence, set one while it is already set. For example: chattr +a /mnt/gfs2/file1 chattr +i /mnt/gfs2/file1 The first command sets the append-only flag. Since they are additive, the second command sets the immutable flag AND append-only flag, since they both coexist in i_diskflags. So the second command should not return an error. This bug caused xfstests generic/545 to fail. This patch simply removes the invalid checks. I also eliminated an unused parm from do_gfs2_set_flags. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent c98c2ca commit a500bd3

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

fs/gfs2/file.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,9 @@ void gfs2_set_inode_flags(struct inode *inode)
213213
* @inode: The inode
214214
* @reqflags: The flags to set
215215
* @mask: Indicates which flags are valid
216-
* @fsflags: The FS_* inode flags passed in
217216
*
218217
*/
219-
static int do_gfs2_set_flags(struct inode *inode, u32 reqflags, u32 mask,
220-
const u32 fsflags)
218+
static int do_gfs2_set_flags(struct inode *inode, u32 reqflags, u32 mask)
221219
{
222220
struct gfs2_inode *ip = GFS2_I(inode);
223221
struct gfs2_sbd *sdp = GFS2_SB(inode);
@@ -237,10 +235,6 @@ static int do_gfs2_set_flags(struct inode *inode, u32 reqflags, u32 mask,
237235
goto out;
238236

239237
error = -EPERM;
240-
if (IS_IMMUTABLE(inode) && (new_flags & GFS2_DIF_IMMUTABLE))
241-
goto out;
242-
if (IS_APPEND(inode) && (new_flags & GFS2_DIF_APPENDONLY))
243-
goto out;
244238
if (!IS_IMMUTABLE(inode)) {
245239
error = gfs2_permission(&init_user_ns, inode, MAY_WRITE);
246240
if (error)
@@ -313,7 +307,7 @@ int gfs2_fileattr_set(struct user_namespace *mnt_userns,
313307
mask &= ~(GFS2_DIF_TOPDIR | GFS2_DIF_INHERIT_JDATA);
314308
}
315309

316-
return do_gfs2_set_flags(inode, gfsflags, mask, fsflags);
310+
return do_gfs2_set_flags(inode, gfsflags, mask);
317311
}
318312

319313
static int gfs2_getlabel(struct file *filp, char __user *label)

0 commit comments

Comments
 (0)