On Mon, 2010-09-20 at 18:18 +0200, Fubo Chen wrote: > On Mon, Aug 30, 2010 at 11:22 AM, Nicholas A. Bellinger > <nab@xxxxxxxxxxxxxxx> wrote: > > From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> > > > > This patch adds the O_SYNC FILEIO subsystem plugin for accessing struct file > > using Linux/VFS struct file_operations. It also includes WriteCache and FUA > > Write Emulation support to struct file using fs/sync.c/vfs_fsync_range() > > > > Signed-off-by: Nicholas A. Bellinger <nab@xxxxxxxxxxxxxxx> > > > > [ ... ] > > > > +static int fd_do_writev(struct fd_request *req, struct se_task *task) > > +{ > > + struct file *fd = req->fd_dev->fd_file; > > + struct scatterlist *sg = task->task_sg; > > + struct iovec iov[req->fd_sg_count]; > > Kernel stack size is 8 KB. On a 64-bit system struct iovec takes 16 > bytes. What happens if req->fd_sg_count is large ? Kernel crash ? > Greetings Fubo, So wrt to a potential 8K stack over here for the local scope iov[] arrays in fd_do_writev() and fd_do_read().. Currently target_core_file.h defines a FD_MAX_SECTORS of 1024, which means that each struct se_task *task here will be containing at most a 1024 sector request. In scatterlist terms for a TCM fabric module like LIO-Target that does 1:1 struct scatterlist w/ PAGE_SIZE allocations, this would be: ((1024 * block_size) / PAGE_SIZE) * sizeof(struct iovec); which for 64-bit uses 2048 bytes of stack for a FD_MAX_SECTORS task. For a fabric module like TCM_Loop that maps incoming Linux/SCSI scatterlist memory to internal TCM memory points and down to FILEIO code, the maximum here is a scatterlist + offset for every block_size sector for certain cases like mkfs* and friends, which means: ((1024 * block_size) / block_size) * sizeof(struct iovec); which for 64-bit uses 16384 bytes for a FD_MAX_SECTORS task with a scatterlist entry per 512-byte logical block. For at least for the latter case this is a problem with 8K stacks, so it looks these will need to convert to dynamic allocation within the local scope. I will push a patch to fix this shortly. Many thanks for your astute observation! --nab -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html