Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*


1196                  */
1197                 dwbuf[i].b_forw = dwbuf[i].b_back = (struct buf *)&dwbuf[i];
1198                 dwbuf[i].av_forw = dwbuf[i].av_back = (struct buf *)&dwbuf[i];
1199         }
1200 }
1201 
1202 /*
1203  * Wait for I/O completion on the buffer; return error code.
1204  * If bp was for synchronous I/O, bp is invalid and associated
1205  * resources are freed on return.
1206  */
1207 int
1208 biowait(struct buf *bp)
1209 {
1210         int error = 0;
1211         struct cpu *cpup;
1212 
1213         ASSERT(SEMA_HELD(&bp->b_sem));
1214 
1215         cpup = CPU;
1216         atomic_add_64(&cpup->cpu_stats.sys.iowait, 1);
1217         DTRACE_IO1(wait__start, struct buf *, bp);
1218 
1219         /*
1220          * In case of panic, busy wait for completion
1221          */
1222         if (panicstr) {
1223                 while ((bp->b_flags & B_DONE) == 0)
1224                         drv_usecwait(10);
1225         } else
1226                 sema_p(&bp->b_io);
1227 
1228         DTRACE_IO1(wait__done, struct buf *, bp);
1229         atomic_add_64(&cpup->cpu_stats.sys.iowait, -1);
1230 
1231         error = geterror(bp);
1232         if ((bp->b_flags & B_ASYNC) == 0) {
1233                 if (bp->b_flags & B_REMAPPED)
1234                         bp_mapout(bp);
1235         }
1236         return (error);
1237 }
1238 
1239 static void
1240 biodone_tnf_probe(struct buf *bp)
1241 {
1242         /* Kernel probe */
1243         TNF_PROBE_3(biodone, "io blockio", /* CSTYLED */,
1244             tnf_device,         device,         bp->b_edev,
1245             tnf_diskaddr,       block,          bp->b_lblkno,
1246             tnf_opaque,         buf,            bp);
1247 }
1248 
1249 /*




1196                  */
1197                 dwbuf[i].b_forw = dwbuf[i].b_back = (struct buf *)&dwbuf[i];
1198                 dwbuf[i].av_forw = dwbuf[i].av_back = (struct buf *)&dwbuf[i];
1199         }
1200 }
1201 
1202 /*
1203  * Wait for I/O completion on the buffer; return error code.
1204  * If bp was for synchronous I/O, bp is invalid and associated
1205  * resources are freed on return.
1206  */
1207 int
1208 biowait(struct buf *bp)
1209 {
1210         int error = 0;
1211         struct cpu *cpup;
1212 
1213         ASSERT(SEMA_HELD(&bp->b_sem));
1214 
1215         cpup = CPU;
1216         atomic_inc_64(&cpup->cpu_stats.sys.iowait);
1217         DTRACE_IO1(wait__start, struct buf *, bp);
1218 
1219         /*
1220          * In case of panic, busy wait for completion
1221          */
1222         if (panicstr) {
1223                 while ((bp->b_flags & B_DONE) == 0)
1224                         drv_usecwait(10);
1225         } else
1226                 sema_p(&bp->b_io);
1227 
1228         DTRACE_IO1(wait__done, struct buf *, bp);
1229         atomic_dec_64(&cpup->cpu_stats.sys.iowait);
1230 
1231         error = geterror(bp);
1232         if ((bp->b_flags & B_ASYNC) == 0) {
1233                 if (bp->b_flags & B_REMAPPED)
1234                         bp_mapout(bp);
1235         }
1236         return (error);
1237 }
1238 
1239 static void
1240 biodone_tnf_probe(struct buf *bp)
1241 {
1242         /* Kernel probe */
1243         TNF_PROBE_3(biodone, "io blockio", /* CSTYLED */,
1244             tnf_device,         device,         bp->b_edev,
1245             tnf_diskaddr,       block,          bp->b_lblkno,
1246             tnf_opaque,         buf,            bp);
1247 }
1248 
1249 /*