Commit f1301897 authored by Andrey Filippov's avatar Andrey Filippov

added more files for debugging

parent 296d54dd
This diff is collapsed.
This diff is collapsed.
...@@ -174,7 +174,7 @@ static unsigned int dio_bio_write_op(struct kiocb *iocb) ...@@ -174,7 +174,7 @@ static unsigned int dio_bio_write_op(struct kiocb *iocb)
return op; return op;
} }
#define DIO_INLINE_BIO_VECS 4 #define DIO_INLINE_BIO_VECS BIO_MAX_PAGES // 4
static void blkdev_bio_end_io_simple(struct bio *bio) static void blkdev_bio_end_io_simple(struct bio *bio)
{ {
...@@ -197,11 +197,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, ...@@ -197,11 +197,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
ssize_t ret; ssize_t ret;
blk_qc_t qc; blk_qc_t qc;
int i; int i;
pr_debug("pos = %lld, nr_pages = %d, type=%d, iov_offset=0x%x, count=%d, iter->iov->iov_base=%p, iter->iov->iov_len=%d, nr_segs = %ld", \
pos, nr_pages, iter->type, iter->iov_offset, iter->count, iter->iov->iov_base, iter->iov->iov_len, iter->nr_segs); // pos - in file
if ((pos | iov_iter_alignment(iter)) & if ((pos | iov_iter_alignment(iter)) &
(bdev_logical_block_size(bdev) - 1)) (bdev_logical_block_size(bdev) - 1)) {
pr_debug("pos = %lld, iov_iter_alignment(iter) = %ld, nr_pages = %d, bdev_logical_block_size(bdev) = %d", pos, iov_iter_alignment(iter), nr_pages, bdev_logical_block_size(bdev));
return -EINVAL; return -EINVAL;
}
if (nr_pages <= DIO_INLINE_BIO_VECS) if (nr_pages <= DIO_INLINE_BIO_VECS)
vecs = inline_vecs; vecs = inline_vecs;
else { else {
...@@ -210,7 +212,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, ...@@ -210,7 +212,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
if (!vecs) if (!vecs)
return -ENOMEM; return -ENOMEM;
} }
pr_debug("DIO_INLINE_BIO_VECS = %d, nr_pages = %d", DIO_INLINE_BIO_VECS, nr_pages);
bio_init(&bio, vecs, nr_pages); bio_init(&bio, vecs, nr_pages);
bio_set_dev(&bio, bdev); bio_set_dev(&bio, bdev);
bio.bi_iter.bi_sector = pos >> 9; bio.bi_iter.bi_sector = pos >> 9;
...@@ -218,12 +220,12 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, ...@@ -218,12 +220,12 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
bio.bi_private = current; bio.bi_private = current;
bio.bi_end_io = blkdev_bio_end_io_simple; bio.bi_end_io = blkdev_bio_end_io_simple;
bio.bi_ioprio = iocb->ki_ioprio; bio.bi_ioprio = iocb->ki_ioprio;
ret = bio_iov_iter_get_pages(&bio, iter); ret = bio_iov_iter_get_pages(&bio, iter);
pr_debug("ret = %d", ret); // -14
if (unlikely(ret)) if (unlikely(ret))
goto out; goto out;
ret = bio.bi_iter.bi_size; ret = bio.bi_iter.bi_size;
// Does nothing as CONFIG_TASK_IO_ACCOUNTING in not defined
if (iov_iter_rw(iter) == READ) { if (iov_iter_rw(iter) == READ) {
bio.bi_opf = REQ_OP_READ; bio.bi_opf = REQ_OP_READ;
if (iter_is_iovec(iter)) if (iter_is_iovec(iter))
...@@ -243,12 +245,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, ...@@ -243,12 +245,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
io_schedule(); io_schedule();
} }
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
pr_debug("after __set_current_state(TASK_RUNNING)");
bio_for_each_segment_all(bvec, &bio, i) { bio_for_each_segment_all(bvec, &bio, i) {
if (should_dirty && !PageCompound(bvec->bv_page)) if (should_dirty && !PageCompound(bvec->bv_page))
set_page_dirty_lock(bvec->bv_page); set_page_dirty_lock(bvec->bv_page);
put_page(bvec->bv_page); put_page(bvec->bv_page);
} }
pr_debug("bio.bi_status = %d", bio.bi_status);
if (unlikely(bio.bi_status)) if (unlikely(bio.bi_status))
ret = blk_status_to_errno(bio.bi_status); ret = blk_status_to_errno(bio.bi_status);
...@@ -332,11 +335,12 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) ...@@ -332,11 +335,12 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
loff_t pos = iocb->ki_pos; loff_t pos = iocb->ki_pos;
blk_qc_t qc = BLK_QC_T_NONE; blk_qc_t qc = BLK_QC_T_NONE;
int ret = 0; int ret = 0;
pr_debug("pos = %lld, nr_pages = %d", pos, nr_pages);
if ((pos | iov_iter_alignment(iter)) & if ((pos | iov_iter_alignment(iter)) &
(bdev_logical_block_size(bdev) - 1)) (bdev_logical_block_size(bdev) - 1)) {
pr_debug("pos = %lld, iov_iter_alignment(iter) = %ld, nr_pages = %d, bdev_logical_block_size(bdev) = %d", pos, iov_iter_alignment(iter), nr_pages, bdev_logical_block_size(bdev));
return -EINVAL; return -EINVAL;
}
bio = bio_alloc_bioset(GFP_KERNEL, nr_pages, &blkdev_dio_pool); bio = bio_alloc_bioset(GFP_KERNEL, nr_pages, &blkdev_dio_pool);
bio_get(bio); /* extra ref for the completion handler */ bio_get(bio); /* extra ref for the completion handler */
...@@ -424,8 +428,8 @@ static ssize_t ...@@ -424,8 +428,8 @@ static ssize_t
blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
{ {
int nr_pages; int nr_pages;
nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES + 1); nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES + 1);
pr_debug("nr_pages = %d, is_sync_kiocb(iocb) = %d", nr_pages, is_sync_kiocb(iocb));
if (!nr_pages) if (!nr_pages)
return 0; return 0;
if (is_sync_kiocb(iocb) && nr_pages <= BIO_MAX_PAGES) if (is_sync_kiocb(iocb) && nr_pages <= BIO_MAX_PAGES)
......
...@@ -466,7 +466,9 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t ...@@ -466,7 +466,9 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
struct kiocb kiocb; struct kiocb kiocb;
struct iov_iter iter; struct iov_iter iter;
ssize_t ret; ssize_t ret;
if (!strncmp(filp->f_path.dentry->d_name.name, "sda2", 4)) {
pr_debug("pos=%llu, len=%d, buf=0x%p", *ppos, len, buf); // pr_debug("pos=%llu, len=%d, buf=0x%p, data=0x%llx", *ppos, len, buf, ((loff_t*) (buf))[0]);
}
init_sync_kiocb(&kiocb, filp); init_sync_kiocb(&kiocb, filp);
kiocb.ki_pos = *ppos; kiocb.ki_pos = *ppos;
iov_iter_init(&iter, WRITE, &iov, 1, len); iov_iter_init(&iter, WRITE, &iov, 1, len);
...@@ -481,6 +483,10 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t ...@@ -481,6 +483,10 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
ssize_t __vfs_write(struct file *file, const char __user *p, size_t count, ssize_t __vfs_write(struct file *file, const char __user *p, size_t count,
loff_t *pos) loff_t *pos)
{ {
if (!strncmp(file->f_path.dentry->d_name.name, "sda2", 4)) {
pr_debug("pos=%llu, count=%d, p=0x%p", *pos, count, p); // pr_debug("pos=%llu, count=%d, p=0x%p, data=0x%llx", *pos, count, p, ((loff_t*) (p))[0]);
}
if (file->f_op->write) if (file->f_op->write)
return file->f_op->write(file, p, count, pos); return file->f_op->write(file, p, count, pos);
else if (file->f_op->write_iter) else if (file->f_op->write_iter)
...@@ -661,19 +667,22 @@ SYSCALL_DEFINE4(pwrite64, unsigned int, fd, const char __user *, buf, ...@@ -661,19 +667,22 @@ SYSCALL_DEFINE4(pwrite64, unsigned int, fd, const char __user *, buf,
{ {
return ksys_pwrite64(fd, buf, count, pos); return ksys_pwrite64(fd, buf, count, pos);
} }
static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter, static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
loff_t *ppos, int type, rwf_t flags) loff_t *ppos, int type, rwf_t flags)
{ {
struct kiocb kiocb; struct kiocb kiocb;
ssize_t ret; ssize_t ret;
pr_debug("pos=%llu, flags=0x%x, type=%s", *ppos, flags, type?"WRITE":"READ"); if (!strncmp(filp->f_path.dentry->d_name.name, "sda2", 4)) {
pr_debug("pos=%llu, flags=0x%x, type=%s", *ppos, flags, type?"WRITE":"READ");
pr_debug("iov_offset=0x%x, count=%d, iter->iov->iov_base=%p, iter->iov->iov_len=%d, nr_segs = %ld", \
iter->iov_offset, iter->count, iter->iov->iov_base, iter->iov->iov_len, iter->nr_segs); // pos - in file
// pr_debug("data=0x%llx", ((loff_t*) (iter->iov->iov_base))[0]);
}
init_sync_kiocb(&kiocb, filp); init_sync_kiocb(&kiocb, filp);
ret = kiocb_set_rw_flags(&kiocb, flags); ret = kiocb_set_rw_flags(&kiocb, flags);
if (ret) if (ret)
return ret; return ret;
kiocb.ki_pos = *ppos; kiocb.ki_pos = *ppos;
if (type == READ) if (type == READ)
ret = call_read_iter(filp, &kiocb, iter); ret = call_read_iter(filp, &kiocb, iter);
else else
......
This diff is collapsed.
...@@ -437,13 +437,13 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start, ...@@ -437,13 +437,13 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
.range_start = start, .range_start = start,
.range_end = end, .range_end = end,
}; };
pr_debug("mapping = %p, start = %lld, end = %lld, sync_mode=%d", mapping, start, end, sync_mode);
if (!mapping_cap_writeback_dirty(mapping)) if (!mapping_cap_writeback_dirty(mapping))
return 0; return 0;
wbc_attach_fdatawrite_inode(&wbc, mapping->host); wbc_attach_fdatawrite_inode(&wbc, mapping->host);
ret = do_writepages(mapping, &wbc); ret = do_writepages(mapping, &wbc);
wbc_detach_inode(&wbc); wbc_detach_inode(&wbc);
pr_debug("ret=%d", ret);
return ret; return ret;
} }
...@@ -651,14 +651,16 @@ int filemap_write_and_wait_range(struct address_space *mapping, ...@@ -651,14 +651,16 @@ int filemap_write_and_wait_range(struct address_space *mapping,
loff_t lstart, loff_t lend) loff_t lstart, loff_t lend)
{ {
int err = 0; int err = 0;
pr_debug("mapping = %p, lstart = %lld, lend = %lld, needs write_back=%d", mapping, lstart, lend, mapping_needs_writeback(mapping));
if (mapping_needs_writeback(mapping)) { if (mapping_needs_writeback(mapping)) {
err = __filemap_fdatawrite_range(mapping, lstart, lend, err = __filemap_fdatawrite_range(mapping, lstart, lend,
WB_SYNC_ALL); WB_SYNC_ALL);
pr_debug("err=%d", err);
/* See comment of filemap_write_and_wait() */ /* See comment of filemap_write_and_wait() */
if (err != -EIO) { if (err != -EIO) {
int err2 = filemap_fdatawait_range(mapping, int err2 = filemap_fdatawait_range(mapping,
lstart, lend); lstart, lend);
pr_debug("err2=%d", err2);
if (!err) if (!err)
err = err2; err = err2;
} else { } else {
...@@ -667,6 +669,7 @@ int filemap_write_and_wait_range(struct address_space *mapping, ...@@ -667,6 +669,7 @@ int filemap_write_and_wait_range(struct address_space *mapping,
} }
} else { } else {
err = filemap_check_errors(mapping); err = filemap_check_errors(mapping);
pr_debug("filemap_check_errors(mapping) -> %d", err);
} }
return err; return err;
} }
...@@ -3005,8 +3008,8 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -3005,8 +3008,8 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from)
ssize_t written; ssize_t written;
size_t write_len; size_t write_len;
pgoff_t end; pgoff_t end;
pr_debug("generic_file_direct_write()");
write_len = iov_iter_count(from); write_len = iov_iter_count(from);
pr_debug("generic_file_direct_write(), pos=%lld, write_len = %d", pos, write_len);
end = (pos + write_len - 1) >> PAGE_SHIFT; end = (pos + write_len - 1) >> PAGE_SHIFT;
if (iocb->ki_flags & IOCB_NOWAIT) { if (iocb->ki_flags & IOCB_NOWAIT) {
...@@ -3017,10 +3020,12 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -3017,10 +3020,12 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from)
} else { } else {
written = filemap_write_and_wait_range(mapping, pos, written = filemap_write_and_wait_range(mapping, pos,
pos + write_len - 1); pos + write_len - 1);
if (written) if (written) {
pr_debug("written = %d", written);
goto out; goto out;
}
} }
pr_debug("not written, written = %d", written);
/* /*
* After a write we want buffered reads to be sure to go to disk to get * After a write we want buffered reads to be sure to go to disk to get
* the new data. We invalidate clean cached page from the region we're * the new data. We invalidate clean cached page from the region we're
...@@ -3038,9 +3043,9 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -3038,9 +3043,9 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from)
return 0; return 0;
goto out; goto out;
} }
pr_debug("Before mapping->a_ops->direct_IO");
written = mapping->a_ops->direct_IO(iocb, from); written = mapping->a_ops->direct_IO(iocb, from);
pr_debug("After mapping->a_ops->direct_IO, written = %d", written);
/* /*
* Finally, try again to invalidate clean pages which might have been * Finally, try again to invalidate clean pages which might have been
* cached by non-direct readahead, or faulted in by get_user_pages() * cached by non-direct readahead, or faulted in by get_user_pages()
...@@ -3225,7 +3230,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -3225,7 +3230,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
} }
if (iocb->ki_flags & IOCB_DIRECT) { if (iocb->ki_flags & IOCB_DIRECT) {
loff_t pos, endbyte; loff_t pos, endbyte;
pr_debug("using IOCB_DIRECT"); pr_debug("using IOCB_DIRECT, count = %d, type = %d",iov_iter_count(from), from->type);
written = generic_file_direct_write(iocb, from); written = generic_file_direct_write(iocb, from);
/* /*
* If the write stopped short of completing, fall back to * If the write stopped short of completing, fall back to
...@@ -3234,8 +3239,11 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -3234,8 +3239,11 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
* not succeed (even if it did, DAX does not handle dirty * not succeed (even if it did, DAX does not handle dirty
* page-cache pages correctly). * page-cache pages correctly).
*/ */
if (written < 0 || !iov_iter_count(from) || IS_DAX(inode)) if (written < 0 || !iov_iter_count(from) || IS_DAX(inode)){
pr_debug("IOCB_DIRECT %s: written = %d, iov_iter_count(from)= %d", (written < 0)?"ERROR":"OK", written, iov_iter_count(from));
goto out; goto out;
}
pr_debug("IOCB_DIRECT NEED MORE: written = %d, iov_iter_count(from)= %d", written, iov_iter_count(from));
status = generic_perform_write(file, from, pos = iocb->ki_pos); status = generic_perform_write(file, from, pos = iocb->ki_pos);
/* /*
......
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