Whamcloud - gitweb
b=9919
authoralex <alex>
Tue, 3 Jan 2006 19:10:41 +0000 (19:10 +0000)
committeralex <alex>
Tue, 3 Jan 2006 19:10:41 +0000 (19:10 +0000)
r=nikita (original fix)

hijacks pages from struct brw_page (allocated by echo_client_kbrw()) by filter_brw(). This

 - fixes problem introduced by 5137 (filter_preprw_*() assumes that pages are preallocated),

 - avoids duplicate allocation,

 - avoids data copying.

Also fixes small defect in filter_iobuf_get().

lustre/obdfilter/filter.c
lustre/obdfilter/filter_io.c

index 4c8ac2d..f93619b 100644 (file)
@@ -1301,9 +1301,15 @@ static int filter_iobuf_pool_init(struct filter_obd *filter)
 void *filter_iobuf_get(struct filter_obd *filter, struct obd_trans_info *oti)
 {
         int thread_id = oti ? oti->oti_thread_id : -1;
-        struct filter_iobuf **pool = &filter->fo_iobuf_pool[thread_id];
+        struct filter_iobuf *pool_local;
+        struct filter_iobuf **pool;
 
+        if (thread_id >= 0) {
         LASSERT(thread_id < filter->fo_iobuf_count);
+                pool = &filter->fo_iobuf_pool[thread_id];
+        } else
+                pool = &pool_local;
+
         if (unlikely(thread_id < 0 || *pool == NULL))
                 filter_alloc_iobuf(filter, OBD_BRW_WRITE,
                                    PTLRPC_MAX_BRW_PAGES, pool);
index abb39e1..03c318e 100644 (file)
@@ -809,6 +809,7 @@ int filter_brw(int cmd, struct obd_export *exp, struct obdo *oa,
                 GOTO(out, ret = -ENOMEM);
 
         for (i = 0; i < oa_bufs; i++) {
+                lnb[i].page = pga[i].pg;
                 rnb[i].offset = pga[i].off;
                 rnb[i].len = pga[i].count;
         }
@@ -820,29 +821,6 @@ int filter_brw(int cmd, struct obd_export *exp, struct obdo *oa,
         if (ret != 0)
                 GOTO(out, ret);
 
-        for (i = 0; i < oa_bufs; i++) {
-                void *virt;
-                obd_off off;
-                void *addr;
-
-                if (lnb[i].page == NULL)
-                        break;
-
-                off = pga[i].off & ~PAGE_MASK;
-                virt = kmap(pga[i].pg);
-                addr = kmap(lnb[i].page);
-
-                /* 2 kmaps == vanishingly small deadlock opportunity */
-
-                if (cmd & OBD_BRW_WRITE)
-                        memcpy(addr + off, virt + off, pga[i].count);
-                else
-                        memcpy(virt + off, addr + off, pga[i].count);
-
-                kunmap(lnb[i].page);
-                kunmap(pga[i].pg);
-        }
-
         ret = filter_commitrw(cmd, exp, oa, 1, &ioo, oa_bufs, lnb, oti, ret);
 
 out: