ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/eio.c
(Generate patch)

Comparing libeio/eio.c (file contents):
Revision 1.9 by root, Mon May 12 00:31:43 2008 UTC vs.
Revision 1.11 by root, Tue May 13 18:50:27 2008 UTC

356 start_thread (); 356 start_thread ();
357} 357}
358 358
359void eio_submit (eio_req *req) 359void eio_submit (eio_req *req)
360{ 360{
361 req->pri += EIO_PRI_BIAS;
362
363 if (req->pri < EIO_PRI_MIN + EIO_PRI_BIAS) req->pri = EIO_PRI_MIN + EIO_PRI_BIAS;
364 if (req->pri > EIO_PRI_MAX + EIO_PRI_BIAS) req->pri = EIO_PRI_MAX + EIO_PRI_BIAS;
365
361 ++nreqs; 366 ++nreqs;
362 367
363 X_LOCK (reqlock); 368 X_LOCK (reqlock);
364 ++nready; 369 ++nready;
365 reqq_push (&req_queue, req); 370 reqq_push (&req_queue, req);
1049 \ 1054 \
1050 req = (eio_req *)calloc (1, sizeof *req); \ 1055 req = (eio_req *)calloc (1, sizeof *req); \
1051 if (!req) \ 1056 if (!req) \
1052 return 0; \ 1057 return 0; \
1053 \ 1058 \
1054 req->type = rtype; \ 1059 req->type = rtype; \
1055 req->pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; \ 1060 req->pri = pri; \
1056 req->finish = cb; \ 1061 req->finish = cb; \
1062 req->data = data; \
1057 req->destroy = eio_api_destroy; 1063 req->destroy = eio_api_destroy;
1058 1064
1059#define SEND eio_submit (req); return req 1065#define SEND eio_submit (req); return req
1060 1066
1061#define PATH \ 1067#define PATH \
1065 { \ 1071 { \
1066 eio_api_destroy (req); \ 1072 eio_api_destroy (req); \
1067 return 0; \ 1073 return 0; \
1068 } 1074 }
1069 1075
1070eio_req *eio_nop (eio_cb cb) 1076eio_req *eio_nop (int pri, eio_cb cb, void *data)
1071{ 1077{
1072 REQ (EIO_NOP); SEND; 1078 REQ (EIO_NOP); SEND;
1073} 1079}
1074 1080
1075eio_req *eio_busy (double delay, eio_cb cb) 1081eio_req *eio_busy (double delay, int pri, eio_cb cb, void *data)
1076{ 1082{
1077 REQ (EIO_BUSY); req->nv1 = delay; SEND; 1083 REQ (EIO_BUSY); req->nv1 = delay; SEND;
1078} 1084}
1079 1085
1080eio_req *eio_sync (eio_cb cb) 1086eio_req *eio_sync (int pri, eio_cb cb, void *data)
1081{ 1087{
1082 REQ (EIO_SYNC); SEND; 1088 REQ (EIO_SYNC); SEND;
1083} 1089}
1084 1090
1085eio_req *eio_fsync (int fd, eio_cb cb) 1091eio_req *eio_fsync (int fd, int pri, eio_cb cb, void *data)
1086{ 1092{
1087 REQ (EIO_FSYNC); req->int1 = fd; SEND; 1093 REQ (EIO_FSYNC); req->int1 = fd; SEND;
1088} 1094}
1089 1095
1090eio_req *eio_fdatasync (int fd, eio_cb cb) 1096eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data)
1091{ 1097{
1092 REQ (EIO_FDATASYNC); req->int1 = fd; SEND; 1098 REQ (EIO_FDATASYNC); req->int1 = fd; SEND;
1093} 1099}
1094 1100
1095eio_req *eio_close (int fd, eio_cb cb) 1101eio_req *eio_close (int fd, int pri, eio_cb cb, void *data)
1096{ 1102{
1097 REQ (EIO_CLOSE); req->int1 = fd; SEND; 1103 REQ (EIO_CLOSE); req->int1 = fd; SEND;
1098} 1104}
1099 1105
1100eio_req *eio_readahead (int fd, off_t offset, size_t length, eio_cb cb) 1106eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data)
1101{ 1107{
1102 REQ (EIO_READAHEAD); req->int1 = fd; req->offs = offset; req->size = length; SEND; 1108 REQ (EIO_READAHEAD); req->int1 = fd; req->offs = offset; req->size = length; SEND;
1103} 1109}
1104 1110
1105eio_req *eio_read (int fd, void *data, size_t length, off_t offset, eio_cb cb) 1111eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
1106{ 1112{
1107 REQ (EIO_READ); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = data; SEND; 1113 REQ (EIO_READ); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
1108} 1114}
1109 1115
1110eio_req *eio_write (int fd, void *data, size_t length, off_t offset, eio_cb cb) 1116eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
1111{ 1117{
1112 REQ (EIO_WRITE); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = data; SEND; 1118 REQ (EIO_WRITE); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
1113} 1119}
1114 1120
1115eio_req *eio_fstat (int fd, eio_cb cb) 1121eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data)
1116{ 1122{
1117 REQ (EIO_FSTAT); req->int1 = fd; SEND; 1123 REQ (EIO_FSTAT); req->int1 = fd; SEND;
1118} 1124}
1119 1125
1120eio_req *eio_futime (int fd, double atime, double mtime, eio_cb cb) 1126eio_req *eio_futime (int fd, double atime, double mtime, int pri, eio_cb cb, void *data)
1121{ 1127{
1122 REQ (EIO_FUTIME); req->int1 = fd; req->nv1 = atime; req->nv2 = mtime; SEND; 1128 REQ (EIO_FUTIME); req->int1 = fd; req->nv1 = atime; req->nv2 = mtime; SEND;
1123} 1129}
1124 1130
1125eio_req *eio_ftruncate (int fd, off_t offset, eio_cb cb) 1131eio_req *eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data)
1126{ 1132{
1127 REQ (EIO_FTRUNCATE); req->int1 = fd; req->offs = offset; SEND; 1133 REQ (EIO_FTRUNCATE); req->int1 = fd; req->offs = offset; SEND;
1128} 1134}
1129 1135
1130eio_req *eio_fchmod (int fd, mode_t mode, eio_cb cb) 1136eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data)
1131{ 1137{
1132 REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND; 1138 REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND;
1133} 1139}
1134 1140
1135eio_req *eio_fchown (int fd, uid_t uid, gid_t gid, eio_cb cb) 1141eio_req *eio_fchown (int fd, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data)
1136{ 1142{
1137 REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND; 1143 REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND;
1138} 1144}
1139 1145
1140eio_req *eio_dup2 (int fd, int fd2, eio_cb cb) 1146eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data)
1141{ 1147{
1142 REQ (EIO_DUP2); req->int1 = fd; req->int2 = fd2; SEND; 1148 REQ (EIO_DUP2); req->int1 = fd; req->int2 = fd2; SEND;
1143} 1149}
1144 1150
1145eio_req *eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, eio_cb cb) 1151eio_req *eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, int pri, eio_cb cb, void *data)
1146{ 1152{
1147 REQ (EIO_SENDFILE); req->int1 = out_fd; req->int2 = in_fd; req->offs = in_offset; req->size = length; SEND; 1153 REQ (EIO_SENDFILE); req->int1 = out_fd; req->int2 = in_fd; req->offs = in_offset; req->size = length; SEND;
1148} 1154}
1149 1155
1150eio_req *eio_open (const char *path, int flags, mode_t mode, eio_cb cb) 1156eio_req *eio_open (const char *path, int flags, mode_t mode, int pri, eio_cb cb, void *data)
1151{ 1157{
1152 REQ (EIO_OPEN); PATH; req->int1 = flags; req->int2 = (long)mode; SEND; 1158 REQ (EIO_OPEN); PATH; req->int1 = flags; req->int2 = (long)mode; SEND;
1153} 1159}
1154 1160
1155eio_req *eio_utime (const char *path, double atime, double mtime, eio_cb cb) 1161eio_req *eio_utime (const char *path, double atime, double mtime, int pri, eio_cb cb, void *data)
1156{ 1162{
1157 REQ (EIO_UTIME); PATH; req->nv1 = atime; req->nv2 = mtime; SEND; 1163 REQ (EIO_UTIME); PATH; req->nv1 = atime; req->nv2 = mtime; SEND;
1158} 1164}
1159 1165
1160eio_req *eio_truncate (const char *path, off_t offset, eio_cb cb) 1166eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data)
1161{ 1167{
1162 REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND; 1168 REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND;
1163} 1169}
1164 1170
1165eio_req *eio_chown (const char *path, uid_t uid, gid_t gid, eio_cb cb) 1171eio_req *eio_chown (const char *path, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data)
1166{ 1172{
1167 REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND; 1173 REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND;
1168} 1174}
1169 1175
1170eio_req *eio_chmod (const char *path, mode_t mode, eio_cb cb) 1176eio_req *eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data)
1171{ 1177{
1172 REQ (EIO_CHMOD); PATH; req->int2 = (long)mode; SEND; 1178 REQ (EIO_CHMOD); PATH; req->int2 = (long)mode; SEND;
1173} 1179}
1174 1180
1175eio_req *eio_mkdir (const char *path, mode_t mode, eio_cb cb) 1181eio_req *eio_mkdir (const char *path, mode_t mode, int pri, eio_cb cb, void *data)
1176{ 1182{
1177 REQ (EIO_MKDIR); PATH; req->int2 = (long)mode; SEND; 1183 REQ (EIO_MKDIR); PATH; req->int2 = (long)mode; SEND;
1178} 1184}
1179 1185
1180static eio_req * 1186static eio_req *
1181eio__1path (int type, const char *path, eio_cb cb) 1187eio__1path (int type, const char *path, int pri, eio_cb cb, void *data)
1182{ 1188{
1183 REQ (type); PATH; SEND; 1189 REQ (type); PATH; SEND;
1184} 1190}
1185 1191
1186eio_req *eio_readlink (const char *path, eio_cb cb) 1192eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data)
1187{ 1193{
1188 return eio__1path (EIO_READLINK, path, cb); 1194 return eio__1path (EIO_READLINK, path, pri, cb, data);
1189} 1195}
1190 1196
1191eio_req *eio_stat (const char *path, eio_cb cb) 1197eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data)
1192{ 1198{
1193 return eio__1path (EIO_STAT, path, cb); 1199 return eio__1path (EIO_STAT, path, pri, cb, data);
1194} 1200}
1195 1201
1196eio_req *eio_lstat (const char *path, eio_cb cb) 1202eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data)
1197{ 1203{
1198 return eio__1path (EIO_LSTAT, path, cb); 1204 return eio__1path (EIO_LSTAT, path, pri, cb, data);
1199} 1205}
1200 1206
1201eio_req *eio_unlink (const char *path, eio_cb cb) 1207eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data)
1202{ 1208{
1203 return eio__1path (EIO_UNLINK, path, cb); 1209 return eio__1path (EIO_UNLINK, path, pri, cb, data);
1204} 1210}
1205 1211
1206eio_req *eio_rmdir (const char *path, eio_cb cb) 1212eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data)
1207{ 1213{
1208 return eio__1path (EIO_RMDIR, path, cb); 1214 return eio__1path (EIO_RMDIR, path, pri, cb, data);
1209} 1215}
1210 1216
1211eio_req *eio_readdir (const char *path, eio_cb cb) 1217eio_req *eio_readdir (const char *path, int pri, eio_cb cb, void *data)
1212{ 1218{
1213 return eio__1path (EIO_READDIR, path, cb); 1219 return eio__1path (EIO_READDIR, path, pri, cb, data);
1214} 1220}
1215 1221
1216eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, eio_cb cb) 1222eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data)
1217{ 1223{
1218 REQ (EIO_MKNOD); PATH; req->int2 = (long)mode; req->int2 = (long)dev; SEND; 1224 REQ (EIO_MKNOD); PATH; req->int2 = (long)mode; req->int2 = (long)dev; SEND;
1219} 1225}
1220 1226
1221static eio_req * 1227static eio_req *
1222eio__2path (int type, const char *path, const char *new_path, eio_cb cb) 1228eio__2path (int type, const char *path, const char *new_path, int pri, eio_cb cb, void *data)
1223{ 1229{
1224 REQ (type); PATH; 1230 REQ (type); PATH;
1225 1231
1226 req->flags |= EIO_FLAG_PTR2_FREE; 1232 req->flags |= EIO_FLAG_PTR2_FREE;
1227 req->ptr2 = strdup (new_path); 1233 req->ptr2 = strdup (new_path);
1232 } 1238 }
1233 1239
1234 SEND; 1240 SEND;
1235} 1241}
1236 1242
1237eio_req *eio_link (const char *path, const char *new_path, eio_cb cb) 1243eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
1238{ 1244{
1239 return eio__2path (EIO_LINK, path, new_path, cb); 1245 return eio__2path (EIO_LINK, path, new_path, pri, cb, data);
1240} 1246}
1241 1247
1242eio_req *eio_symlink (const char *path, const char *new_path, eio_cb cb) 1248eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
1243{ 1249{
1244 return eio__2path (EIO_SYMLINK, path, new_path, cb); 1250 return eio__2path (EIO_SYMLINK, path, new_path, pri, cb, data);
1245} 1251}
1246 1252
1247eio_req *eio_rename (const char *path, const char *new_path, eio_cb cb) 1253eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
1248{ 1254{
1249 return eio__2path (EIO_RENAME, path, new_path, cb); 1255 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data);
1256}
1257
1258eio_req *eio_grp (eio_cb cb, void *data)
1259{
1260 const int pri = EIO_PRI_MAX;
1261
1262 REQ (EIO_GROUP); SEND;
1250} 1263}
1251 1264
1252#undef REQ 1265#undef REQ
1253#undef PATH 1266#undef PATH
1254#undef SEND 1267#undef SEND

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines