Commit 73a61e86 authored by Dean Roehrich's avatar Dean Roehrich Committed by Nathan Scott

[XFS] DMAPI deadlock prevention when interacting with the IO path.

SGI Modid: xfs-linux:xfs-kern:167547a
parent efe3629c
...@@ -730,7 +730,7 @@ xfs_write( ...@@ -730,7 +730,7 @@ xfs_write(
if ((DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_WRITE) && if ((DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_WRITE) &&
!(ioflags & IO_INVIS) && !eventsent)) { !(ioflags & IO_INVIS) && !eventsent)) {
loff_t savedsize = *offset; loff_t savedsize = *offset;
int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG(ioflags); int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags);
xfs_iunlock(xip, XFS_ILOCK_EXCL); xfs_iunlock(xip, XFS_ILOCK_EXCL);
error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp, error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp,
......
...@@ -169,19 +169,22 @@ typedef enum { ...@@ -169,19 +169,22 @@ typedef enum {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21) #if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21)
/* i_alloc_sem was added in 2.4.22-pre1 */ /* i_alloc_sem was added in 2.4.22-pre1 */
#define DM_FLAGS_IALLOCSEM 0x010 /* thread holds i_alloc_sem */ #define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
#endif #endif
#endif #endif
/* /*
* Based on IO_ISDIRECT, decide which i_ flag is set. * Based on IO_ISDIRECT, decide which i_ flag is set.
*/ */
#ifdef DM_FLAGS_IALLOCSEM #ifdef DM_FLAGS_IALLOCSEM_RD
#define DM_SEM_FLAG(ioflags) (((ioflags) & IO_ISDIRECT) ? \ #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
DM_FLAGS_IALLOCSEM : DM_FLAGS_ISEM) DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_ISEM)
#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
#else #else
#define DM_SEM_FLAG(ioflags) (((ioflags) & IO_ISDIRECT) ? \ #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
0 : DM_FLAGS_ISEM) 0 : DM_FLAGS_ISEM)
#define DM_SEM_FLAG_WR (DM_FLAGS_ISEM)
#endif #endif
/* /*
......
...@@ -413,8 +413,9 @@ xfs_setattr( ...@@ -413,8 +413,9 @@ xfs_setattr(
} else { } else {
if (DM_EVENT_ENABLED (vp->v_vfsp, ip, DM_EVENT_TRUNCATE) && if (DM_EVENT_ENABLED (vp->v_vfsp, ip, DM_EVENT_TRUNCATE) &&
!(flags & ATTR_DMI)) { !(flags & ATTR_DMI)) {
int dmflags = AT_DELAY_FLAG(flags) | DM_SEM_FLAG_WR;
code = XFS_SEND_DATA(mp, DM_EVENT_TRUNCATE, vp, code = XFS_SEND_DATA(mp, DM_EVENT_TRUNCATE, vp,
vap->va_size, 0, AT_DELAY_FLAG(flags), NULL); vap->va_size, 0, dmflags, NULL);
if (code) { if (code) {
lock_flags = 0; lock_flags = 0;
goto error_return; goto error_return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment