Hi Dean,
Yes, This code is for the 2.6.
If xfs_write isn't direct IO, ret is used as last argment of
generic_file_buffered_write().
This argment is data buffer offset. So, when retry happen, data pointer is
shift -28(-ENOSPC) bytes.
retry:
/* We can write back this queue in page reclaim */
current->backing_dev_info = mapping->backing_dev_info;
if ((ioflags & IO_ISDIRECT)) {
....
....
} else {
xfs_rw_enter_trace(XFS_WRITE_ENTER, io, (void *)iovp, segs,
*offset, ioflags);
ret = generic_file_buffered_write(iocb, iovp, segs,
pos, offset, count, ret); <-------- this
}
Regards,
Kenji
> >From: Kenji Munakata <munaken@xxxxxxxxxxxxxxxxxxx>
> >Hi there,
> >
> >I found that data & size corrupting when the ENOSPC(with DMAPI) retrial
> >succee
> >ds.
> >It seems that data offset is not reset at retry.
> >following patches are appended.
> >
> >--- xfs_lrw.c.ORG 2005-02-28 11:56:18.405763312 +0900
> >+++ xfs_lrw.c 2005-02-28 11:57:07.543293272 +0900
> >@@ -862,24 +862,25 @@
> > if ((ret == -ENOSPC) &&
> > DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_NOSPACE) &&
> > !(ioflags & IO_INVIS)) {
> >
> > xfs_rwunlock(bdp, locktype);
> > error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
> > DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
> > 0, 0, 0); /* Delay flag intentionally
> > unused
> >*/
> > if (error)
> > goto out_unlock_isem;
> > xfs_rwlock(bdp, locktype);
> > pos = xip->i_d.di_size;
> >+ ret = 0;
> > goto retry;
> > }
>
>
> This looks like code for the 2.6 kernel.
>
> In xfs_write I see that when we jump to 'retry', 'ret' will be used as an
> lvalue before it is tested again.
>
> Maybe 'pos' is not being set properly? Is di_size changing? It can, given
> that this thread may not hold any locks while it was in the DMAPI queues to
> deliver the NOSPACE event--there's nothing to prevent another thread from
> coming in and changing the size of the file before you can fully unwind from
> delivering the NOSPACE event.
>
> It looks like we sometimes hold i_sem while delivering NOSPACE. Have to fix
> that, too. Do you know if need_isem was set when you delivered NOSPACE?
>
> Dean
>
|