ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.xs
(Generate patch)

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.213 by root, Tue Apr 10 05:01:33 2012 UTC vs.
Revision 1.219 by root, Fri Jul 27 18:43:25 2012 UTC

167 req->result = -1; 167 req->result = -1;
168 168
169#if HAVE_FIEMAP 169#if HAVE_FIEMAP
170 int count = req->int3; 170 int count = req->int3;
171 171
172 /* heuristic: first try with 64 extents if we don't know how many, */ 172 /* heuristic: first try with 72 extents if we don't know how many, */
173 /* as most files have (hopefully) fewer than this many extents */ 173 /* as most files have (hopefully) fewer than this many extents */
174 /* in fact, most should have <= 2, so maybe the 72 below is probably overkill */ 174 /* in fact, most should have <= 2, so the 72 below is probably overkill */
175 if (count < 0) 175 if (count < 0)
176 count = 72; /* for what it's worth, 72 extents fit nicely into 4kb */ 176 count = 72; /* for what it's worth, 72 extents fit nicely into 4kb */
177 177
178 for (;;) 178 for (;;)
179 { 179 {
194 return; 194 return;
195 195
196 if (req->int3 >= 0) 196 if (req->int3 >= 0)
197 break; /* when not autosizing we are done */ 197 break; /* when not autosizing we are done */
198 198
199 if (fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST) 199 if (fiemap->fm_mapped_extents < count)
200 break; /* autosizing successful, we are done */ 200 /* either autosizing succeeded,
201 * or the file had no extents
202 * or we luckily had enough space */
203 break;
201 204
205 /* some kernels overwrite fm_length, so just reset everything */
206 fiemap->fm_start = req->offs;
207 fiemap->fm_length = req->size;
202 fiemap->fm_flags = req->int2; 208 fiemap->fm_flags = req->int2;
203 fiemap->fm_extent_count = 0; 209 fiemap->fm_extent_count = 0;
204 210
205 if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) 211 if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap))
206 return; 212 return;
207 213
214 /* to work around a kernel bug, we allocate one more */
208 count = fiemap->fm_mapped_extents; 215 count = fiemap->fm_mapped_extents + 1;
209 216
210 free (fiemap); 217 free (fiemap);
211 } 218 }
212 219
213 req->result = 0; 220 req->result = 0;
983 const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) 990 const_eio (SYNC_FILE_RANGE_WAIT_BEFORE)
984 const_eio (SYNC_FILE_RANGE_WRITE) 991 const_eio (SYNC_FILE_RANGE_WRITE)
985 const_eio (SYNC_FILE_RANGE_WAIT_AFTER) 992 const_eio (SYNC_FILE_RANGE_WAIT_AFTER)
986 993
987 const_eio (FALLOC_FL_KEEP_SIZE) 994 const_eio (FALLOC_FL_KEEP_SIZE)
995 const_eio (FALLOC_FL_PUNCH_HOLE)
988 996
989 const_eio (READDIR_DENTS) 997 const_eio (READDIR_DENTS)
990 const_eio (READDIR_DIRS_FIRST) 998 const_eio (READDIR_DIRS_FIRST)
991 const_eio (READDIR_STAT_ORDER) 999 const_eio (READDIR_STAT_ORDER)
992 const_eio (READDIR_FOUND_UNKNOWN) 1000 const_eio (READDIR_FOUND_UNKNOWN)
1215 } 1223 }
1216 else 1224 else
1217 { 1225 {
1218 /* read: check type and grow scalar as necessary */ 1226 /* read: check type and grow scalar as necessary */
1219 SvUPGRADE (data, SVt_PV); 1227 SvUPGRADE (data, SVt_PV);
1228 if (SvLEN (data) >= SvCUR (data))
1220 svptr = SvGROW (data, len + dataoffset + 1); 1229 svptr = SvGROW (data, len + dataoffset + 1);
1230 else if (SvCUR (data) < len + dataoffset)
1231 croak ("length + dataoffset outside of scalar, and cannot grow");
1221 } 1232 }
1222 1233
1223 { 1234 {
1224 dREQ; 1235 dREQ;
1225 1236
1528 1539
1529void 1540void
1530aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) 1541aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef)
1531 PPCODE: 1542 PPCODE:
1532{ 1543{
1533 int fd = s_fileno_croak (fh, 0); 1544 int fd = s_fileno_croak (fh, 0);
1534 dREQ; 1545 dREQ;
1535 1546
1536 req->type = EIO_CUSTOM; 1547 req->type = EIO_CUSTOM;
1537 req->sv1 = newSVsv (fh); 1548 req->sv1 = newSVsv (fh);
1538 req->int1 = fd; 1549 req->int1 = fd;
1686 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); 1697 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count);
1687 OUTPUT: 1698 OUTPUT:
1688 RETVAL 1699 RETVAL
1689 1700
1690void 1701void
1691mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) 1702mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0)
1692 PPCODE: 1703 PPCODE:
1693 sv_unmagic (scalar, MMAP_MAGIC); 1704 sv_unmagic (scalar, MMAP_MAGIC);
1694{ 1705{
1695 int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; 1706 int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1;
1696 void *addr = (void *)mmap (0, length, prot, flags, fd, offset); 1707 void *addr = (void *)mmap (0, length, prot, flags, fd, offset);
1729 ALIAS: 1740 ALIAS:
1730 mprotect = 1 1741 mprotect = 1
1731 CODE: 1742 CODE:
1732{ 1743{
1733 STRLEN svlen; 1744 STRLEN svlen;
1734 void *addr = SvPVbyte (scalar, svlen); 1745 void *addr = SvPVbyte (scalar, svlen);
1735 size_t len = SvUV (length); 1746 size_t len = SvUV (length);
1736 1747
1737 if (offset < 0) 1748 if (offset < 0)
1738 offset += svlen; 1749 offset += svlen;
1739 1750

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines