Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: trunk/kernel/block-io.c
- ===================================================================
- --- trunk/kernel/block-io.c (revision 470)
- +++ trunk/kernel/block-io.c (working copy)
- @@ -58,14 +58,13 @@
- struct bio *tio_bio = NULL, *bio = NULL, *biotail = NULL;
- struct blk_plug plug;
- - u32 offset = tio->offset;
- u32 size = tio->size;
- u32 tio_index = 0;
- int max_pages = 1;
- int err = 0;
- - loff_t ppos = ((loff_t) tio->idx << PAGE_SHIFT) + offset;
- + loff_t ppos = tio->offset;
- /* Calculate max_pages for bio_alloc (memory saver) */
- if (bdev_q)
- @@ -102,19 +101,17 @@
- /* Loop for filling bio */
- while (tio_index < tio->pg_cnt) {
- - unsigned int bytes = PAGE_SIZE - offset;
- + unsigned int bytes = PAGE_SIZE;
- if (bytes > size)
- bytes = size;
- - if (!bio_add_page(bio, tio->pvec[tio_index], bytes, offset))
- + if (!bio_add_page(bio, tio->pvec[tio_index], bytes, 0))
- break;
- size -= bytes;
- ppos += bytes;
- - offset = 0;
- -
- tio_index++;
- }
- }
- Index: trunk/kernel/target_disk.c
- ===================================================================
- --- trunk/kernel/target_disk.c (revision 470)
- +++ trunk/kernel/target_disk.c (working copy)
- @@ -291,7 +291,7 @@
- size = min(size & ~(8 - 1), len + 8);
- assert(!tio);
- - tio = cmnd->tio = tio_alloc(get_pgcnt(size, 0));
- + tio = cmnd->tio = tio_alloc(get_pgcnt(size));
- tio_set(tio, size, 0);
- data = page_address(tio->pvec[idx]);
- Index: trunk/kernel/iscsi.c
- ===================================================================
- --- trunk/kernel/iscsi.c (revision 470)
- +++ trunk/kernel/iscsi.c (working copy)
- @@ -331,8 +331,7 @@
- rsp->pdu.datasize = sizeof(struct iscsi_sense_data) +
- IET_SENSE_BUF_SIZE;
- - rsp->tio->size = (rsp->pdu.datasize + 3) & -4;
- - rsp->tio->offset = 0;
- + tio_set(rsp->tio, (rsp->pdu.datasize + 3) & -4, 0);
- }
- return rsp;
- @@ -706,18 +705,15 @@
- char *addr;
- dprintk(D_GENERIC, "%p %u,%u\n", tio, offset, size);
- - offset += tio->offset;
- if (!size)
- return 0;
- - if (!(offset < tio->offset + tio->size) ||
- - !(offset + size <= tio->offset + tio->size)) {
- - eprintk("%u %u %u %u", offset, size, tio->offset, tio->size);
- + if (!(offset + size <= tio->pg_cnt * PAGE_CACHE_SIZE)) {
- + eprintk("bad offset: o:%u s:%u total:%lu",
- + offset, size, tio->pg_cnt * PAGE_CACHE_SIZE);
- return -EIO;
- }
- - assert(offset < tio->offset + tio->size);
- - assert(offset + size <= tio->offset + tio->size);
- idx = offset >> PAGE_CACHE_SHIFT;
- offset &= ~PAGE_CACHE_MASK;
- @@ -924,7 +920,7 @@
- conn->read_msg.msg_iov = conn->read_iov;
- if (cmnd->pdu.bhs.itt != cpu_to_be32(ISCSI_RESERVED_TAG)) {
- struct tio *tio;
- - int pg_cnt = get_pgcnt(size, 0);
- + int pg_cnt = get_pgcnt(size);
- assert(pg_cnt < ISCSI_CONN_IOV_MAX);
- cmnd->tio = tio = tio_alloc(pg_cnt);
- @@ -1030,7 +1026,7 @@
- }
- set_offset_and_length(req->lun, req_hdr->scb, &offset, &length);
- - req->tio = tio_alloc(get_pgcnt(length, offset));
- + req->tio = tio_alloc(get_pgcnt(length));
- tio_set(req->tio, length, offset);
- break;
- }
- @@ -1070,7 +1066,7 @@
- if (cmnd_write_size(req) != length)
- eprintk("%x %u %u\n", cmnd_itt(req), cmnd_write_size(req), length);
- - req->tio = tio_alloc(get_pgcnt(length, offset));
- + req->tio = tio_alloc(get_pgcnt(length));
- tio_set(req->tio, length, offset);
- if (req->pdu.datasize) {
- @@ -1451,7 +1447,7 @@
- rsp->tio = req->tio;
- }
- - assert(get_pgcnt(req->pdu.datasize, 0) < ISCSI_CONN_IOV_MAX);
- + assert(get_pgcnt(req->pdu.datasize) < ISCSI_CONN_IOV_MAX);
- rsp->pdu.datasize = req->pdu.datasize;
- iscsi_cmnd_init_write(rsp);
- } else {
- @@ -1609,10 +1605,8 @@
- static void __cmnd_send_pdu(struct iscsi_conn *conn, struct tio *tio, u32 offset, u32 size)
- {
- dprintk(D_GENERIC, "%p %u,%u\n", tio, offset, size);
- - offset += tio->offset;
- - assert(offset <= tio->offset + tio->size);
- - assert(offset + size <= tio->offset + tio->size);
- + assert(offset + size <= tio->pg_cnt * PAGE_CACHE_SIZE);
- conn->write_tcmnd = tio;
- conn->write_offset = offset;
- Index: trunk/kernel/digest.c
- ===================================================================
- --- trunk/kernel/digest.c (revision 470)
- +++ trunk/kernel/digest.c (working copy)
- @@ -200,29 +200,22 @@
- {
- struct scatterlist *sg = cmnd->conn->hash_sg;
- u32 size, length;
- - int i, idx, count;
- + int i, idx;
- unsigned int nbytes;
- size = cmnd->pdu.datasize;
- nbytes = size = (size + 3) & ~3;
- - offset += tio->offset;
- idx = offset >> PAGE_CACHE_SHIFT;
- offset &= ~PAGE_CACHE_MASK;
- - count = get_pgcnt(size, offset);
- - assert(idx + count <= tio->pg_cnt);
- - assert(count <= ISCSI_CONN_IOV_MAX);
- + assert(idx <= ISCSI_CONN_IOV_MAX);
- sg_init_table(sg, ARRAY_SIZE(cmnd->conn->hash_sg));
- crypto_hash_init(hash);
- - for (i = 0; size; i++) {
- - if (offset + size > PAGE_CACHE_SIZE)
- - length = PAGE_CACHE_SIZE - offset;
- - else
- - length = size;
- -
- + for (i = 0; size > 0; i++) {
- + length = min_t(u32, PAGE_CACHE_SIZE - offset, size);
- sg_set_page(&sg[i], tio->pvec[idx + i], length, offset);
- size -= length;
- offset = 0;
- Index: trunk/kernel/iscsi.h
- ===================================================================
- --- trunk/kernel/iscsi.h (revision 470)
- +++ trunk/kernel/iscsi.h (working copy)
- @@ -56,16 +56,15 @@
- int nop_timeout;
- };
- +/* target io */
- struct tio {
- - u32 pg_cnt;
- + u32 pg_cnt; /* total page count */
- - pgoff_t idx;
- - u32 offset;
- - u32 size;
- + loff_t offset; /* byte offset on target */
- + u32 size; /* total io bytes */
- + struct page **pvec; /* array of pages holding data */
- - struct page **pvec;
- -
- - atomic_t count;
- + atomic_t count; /* ref count */
- };
- struct tio_iterator {
- @@ -455,7 +454,7 @@
- void ua_establish_for_all_sessions(struct iscsi_target *, u32 lun, u8 asc,
- u8 ascq);
- -#define get_pgcnt(size, offset) ((((size) + ((offset) & ~PAGE_CACHE_MASK)) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)
- +#define get_pgcnt(size) (((size) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)
- static inline void iscsi_cmnd_get_length(struct iscsi_pdu *pdu)
- {
- Index: trunk/kernel/file-io.c
- ===================================================================
- --- trunk/kernel/file-io.c (revision 470)
- +++ trunk/kernel/file-io.c (working copy)
- @@ -24,31 +24,22 @@
- struct file *filp;
- mm_segment_t oldfs;
- struct page *page;
- - u32 offset, size;
- - loff_t ppos, count;
- + loff_t ppos;
- char *buf;
- int i, err = 0;
- - ssize_t ret;
- + u32 count, size, ret;
- assert(p);
- filp = p->filp;
- size = tio->size;
- - offset= tio->offset;
- + ppos = tio->offset;
- - ppos = (loff_t) tio->idx << PAGE_CACHE_SHIFT;
- - ppos += offset;
- -
- for (i = 0; i < tio->pg_cnt; i++) {
- page = tio->pvec[i];
- assert(page);
- buf = page_address(page);
- - buf += offset;
- + count = min_t(u32, PAGE_CACHE_SIZE, size);
- - if (offset + size > PAGE_CACHE_SIZE)
- - count = PAGE_CACHE_SIZE - offset;
- - else
- - count = size;
- -
- oldfs = get_fs();
- set_fs(get_ds());
- @@ -60,12 +51,12 @@
- set_fs(oldfs);
- if (ret != count) {
- - eprintk("I/O error %lld, %ld\n", count, (long) ret);
- + eprintk("I/O error %u, %ld\n", count, (long) ret);
- err = -EIO;
- + break;
- }
- size -= count;
- - offset = 0;
- }
- assert(!size);
- @@ -81,8 +72,7 @@
- int res;
- if (tio) {
- - ppos = (loff_t) tio->idx << PAGE_CACHE_SHIFT;
- - ppos += tio->offset;
- + ppos = tio->offset;
- count = tio->size;
- } else {
- ppos = 0;
- Index: trunk/kernel/persist.c
- ===================================================================
- --- trunk/kernel/persist.c (revision 470)
- +++ trunk/kernel/persist.c (working copy)
- @@ -261,7 +261,7 @@
- case SERVICE_ACTION_READ_FULL_STATUS:
- if (allocation_length == 0)
- return;
- - cmnd->tio = tio_alloc(get_pgcnt(allocation_length, 0));
- + cmnd->tio = tio_alloc(get_pgcnt(allocation_length));
- break;
- default:
- eprintk("%#Lx:%hu: invalid PR In Service Action %x\n",
- Index: trunk/kernel/tio.c
- ===================================================================
- --- trunk/kernel/tio.c (revision 470)
- +++ trunk/kernel/tio.c (working copy)
- @@ -44,7 +44,6 @@
- tio = kmem_cache_alloc(tio_cache, GFP_KERNEL | __GFP_NOFAIL);
- tio->pg_cnt = 0;
- - tio->idx = 0;
- tio->offset = 0;
- tio->size = 0;
- tio->pvec = NULL;
- @@ -119,8 +118,7 @@
- void tio_set(struct tio *tio, u32 size, loff_t offset)
- {
- - tio->idx = offset >> PAGE_CACHE_SHIFT;
- - tio->offset = offset & ~PAGE_CACHE_MASK;
- + tio->offset = offset;
- tio->size = size;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement