2022-08-22 15:24 GMT+09:00, Hyunchul Lee <hyc.lee@xxxxxxxxx>: > 2022년 8월 22일 (월) 오전 11:47, Namjae Jeon <linkinjeon@xxxxxxxxxx>님이 작성: >> >> 2022-08-22 11:14 GMT+09:00, Hyunchul Lee <hyc.lee@xxxxxxxxx>: >> > 2022년 8월 22일 (월) 오전 9:51, Namjae Jeon <linkinjeon@xxxxxxxxxx>님이 작성: >> >> >> >> 2022-08-19 13:35 GMT+09:00, Hyunchul Lee <hyc.lee@xxxxxxxxx>: >> >> > if iterate_dir() returns non-negative value, >> >> > caller has to treat it as normal and >> >> > check there is any error while populating >> >> > dentry information. ksmbd doesn't have to >> >> > do anything because ksmbd already >> >> > checks too small OutputBufferLength to >> >> > store one file information. >> >> > >> >> > And because ctx->pos is set to file->f_pos >> >> > when iterative_dir is called, remove >> >> > restart_ctx(). >> >> Shouldn't we get rid of the useless restart_ctx() ? >> >> >> > >> > There is one place to call this function. We can >> > replace that with ctx->pos = 0 and remove this function. >> Why should we do ctx->pos = 0 there ? > > restart_ctx has to be deleted. I misunderstood it, > >> > >> >> > >> >> > This patch fixes some failure of >> >> > SMB2_QUERY_DIRECTORY, which happens when >> >> > ntfs3 is local filesystem. >> >> > >> >> > Signed-off-by: Hyunchul Lee <hyc.lee@xxxxxxxxx> >> >> > --- >> >> > fs/ksmbd/smb2pdu.c | 6 ++---- >> >> > 1 file changed, 2 insertions(+), 4 deletions(-) >> >> > >> >> > diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c >> >> > index 53c91ab02be2..6716c4e3c16d 100644 >> >> > --- a/fs/ksmbd/smb2pdu.c >> >> > +++ b/fs/ksmbd/smb2pdu.c >> >> > @@ -3970,11 +3970,9 @@ int smb2_query_dir(struct ksmbd_work *work) >> >> > */ >> >> > if (!d_info.out_buf_len && !d_info.num_entry) >> >> > goto no_buf_len; >> >> > - if (rc == 0) >> >> > - restart_ctx(&dir_fp->readdir_data.ctx); >> >> > - if (rc == -ENOSPC) >> >> > + if (rc > 0 || rc == -ENOSPC) >> >> Do you know why -ENOSPC error is ignored ? >> >> >> > >> > I don't know why and can't find the commit history >> > for this. >> After checking if -ENOSPC error is returned, there is no need to leave >> it if it is not needed. > > In most cases, -ENOSPC is not returned. Because the value > is set to the return value from filesystems' iterate or iterate_share, > and most file systems don't allocate disk space for this operation. > > But we cannot guarantee this. So how about changing handling iterate_dir > like gendents system call. Even if an error code is returned by > iterate_dir, > it treats as normal if several child files are iterated and the buffer > is filled with > information about those. Among the errors of the smb2 query directory in the specification, there is a file corruption error response type(STATUS_FILE_CORRUPT_ERROR). Can you check when smb server return that error response for smb2 query directory? > >> > >> >> Thanks. >> >> > rc = 0; >> >> > - if (rc) >> >> > + else if (rc) >> >> > goto err_out; >> >> > >> >> > d_info.wptr = d_info.rptr; >> >> > -- >> >> > 2.17.1 >> >> > >> >> > >> > >> > >> > >> > -- >> > Thanks, >> > Hyunchul >> > > > > > -- > Thanks, > Hyunchul >