Skip to content

Commit 2af8217

Browse files
committed
Merge tag 'ovl-fixes-5.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs
Pull overlayfs fixes from Miklos Szeredi: "Fix three bugs introduced in this cycle" * tag 'ovl-fixes-5.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs: ovl: fix lockdep warning for async write ovl: fix some xino configurations ovl: fix lock in ovl_llseek()
2 parents 78511ed + c853680 commit 2af8217

5 files changed

Lines changed: 23 additions & 4 deletions

File tree

fs/overlayfs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ config OVERLAY_FS_XINO_AUTO
9393
bool "Overlayfs: auto enable inode number mapping"
9494
default n
9595
depends on OVERLAY_FS
96+
depends on 64BIT
9697
help
9798
If this config option is enabled then overlay filesystems will use
9899
unused high bits in undelying filesystem inode numbers to map all

fs/overlayfs/file.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ static void ovl_aio_cleanup_handler(struct ovl_aio_req *aio_req)
244244
if (iocb->ki_flags & IOCB_WRITE) {
245245
struct inode *inode = file_inode(orig_iocb->ki_filp);
246246

247+
/* Actually acquired in ovl_write_iter() */
248+
__sb_writers_acquired(file_inode(iocb->ki_filp)->i_sb,
249+
SB_FREEZE_WRITE);
247250
file_end_write(iocb->ki_filp);
248251
ovl_copyattr(ovl_inode_real(inode), inode);
249252
}
@@ -346,6 +349,9 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
346349
goto out;
347350

348351
file_start_write(real.file);
352+
/* Pacify lockdep, same trick as done in aio_write() */
353+
__sb_writers_release(file_inode(real.file)->i_sb,
354+
SB_FREEZE_WRITE);
349355
aio_req->fd = real;
350356
real.flags = 0;
351357
aio_req->orig_iocb = iocb;

fs/overlayfs/overlayfs.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,12 @@ static inline unsigned int ovl_xino_bits(struct super_block *sb)
318318
return ovl_same_dev(sb) ? OVL_FS(sb)->xino_mode : 0;
319319
}
320320

321-
static inline int ovl_inode_lock(struct inode *inode)
321+
static inline void ovl_inode_lock(struct inode *inode)
322+
{
323+
mutex_lock(&OVL_I(inode)->lock);
324+
}
325+
326+
static inline int ovl_inode_lock_interruptible(struct inode *inode)
322327
{
323328
return mutex_lock_interruptible(&OVL_I(inode)->lock);
324329
}

fs/overlayfs/super.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,8 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
14111411
if (ofs->config.xino == OVL_XINO_ON)
14121412
pr_info("\"xino=on\" is useless with all layers on same fs, ignore.\n");
14131413
ofs->xino_mode = 0;
1414+
} else if (ofs->config.xino == OVL_XINO_OFF) {
1415+
ofs->xino_mode = -1;
14141416
} else if (ofs->config.xino == OVL_XINO_ON && ofs->xino_mode < 0) {
14151417
/*
14161418
* This is a roundup of number of bits needed for encoding
@@ -1623,8 +1625,13 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
16231625
sb->s_stack_depth = 0;
16241626
sb->s_maxbytes = MAX_LFS_FILESIZE;
16251627
/* Assume underlaying fs uses 32bit inodes unless proven otherwise */
1626-
if (ofs->config.xino != OVL_XINO_OFF)
1628+
if (ofs->config.xino != OVL_XINO_OFF) {
16271629
ofs->xino_mode = BITS_PER_LONG - 32;
1630+
if (!ofs->xino_mode) {
1631+
pr_warn("xino not supported on 32bit kernel, falling back to xino=off.\n");
1632+
ofs->config.xino = OVL_XINO_OFF;
1633+
}
1634+
}
16281635

16291636
/* alloc/destroy_inode needed for setting up traps in inode cache */
16301637
sb->s_op = &ovl_super_operations;

fs/overlayfs/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ int ovl_copy_up_start(struct dentry *dentry, int flags)
509509
struct inode *inode = d_inode(dentry);
510510
int err;
511511

512-
err = ovl_inode_lock(inode);
512+
err = ovl_inode_lock_interruptible(inode);
513513
if (!err && ovl_already_copied_up_locked(dentry, flags)) {
514514
err = 1; /* Already copied up */
515515
ovl_inode_unlock(inode);
@@ -764,7 +764,7 @@ int ovl_nlink_start(struct dentry *dentry)
764764
return err;
765765
}
766766

767-
err = ovl_inode_lock(inode);
767+
err = ovl_inode_lock_interruptible(inode);
768768
if (err)
769769
return err;
770770

0 commit comments

Comments
 (0)