Commit 0890b421 authored by Rob Latham's avatar Rob Latham
Browse files

[svn-r7926] partial revert and redo of r7923: as daveg point's out better approach to fix

the macro instead of the N places macro gets used..
parent 2355d229
......@@ -18,9 +18,8 @@
ADIO_WriteContig(fd, writebuf, writebuf_len, MPI_BYTE, \
ADIO_EXPLICIT_OFFSET, writebuf_off, \
&status1, error_code); \
if (!(fd->atomicity)) { \
if (!(fd->atomicity)) \
ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
} \
if (*error_code != MPI_SUCCESS) { \
*error_code = MPIO_Err_create_code(*error_code, \
MPIR_ERR_RECOVERABLE, \
......@@ -36,9 +35,8 @@
writebuf_len = (unsigned) ADIOI_MIN(end_offset - writebuf_off + 1, \
(writebuf_off / stripe_size + 1) * \
stripe_size - writebuf_off); \
if (!(fd->atomicity)) { \
if (!(fd->atomicity)) \
ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
} \
ADIO_ReadContig(fd, writebuf, writebuf_len, MPI_BYTE, \
ADIO_EXPLICIT_OFFSET, \
writebuf_off, &status1, error_code); \
......@@ -60,9 +58,8 @@
while (write_sz != req_len) { \
ADIO_WriteContig(fd, writebuf, writebuf_len, MPI_BYTE, \
ADIO_EXPLICIT_OFFSET, writebuf_off, &status1, error_code); \
if (!(fd->atomicity)) { \
if (!(fd->atomicity)) \
ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
} \
if (*error_code != MPI_SUCCESS) { \
*error_code = MPIO_Err_create_code(*error_code, \
MPIR_ERR_RECOVERABLE, myname, \
......@@ -78,9 +75,8 @@
writebuf_len = (unsigned) ADIOI_MIN(end_offset - writebuf_off + 1, \
(writebuf_off / stripe_size + 1) * \
stripe_size - writebuf_off); \
if (!(fd->atomicity)) { \
if (!(fd->atomicity)) \
ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
} \
ADIO_ReadContig(fd, writebuf, writebuf_len, MPI_BYTE, \
ADIO_EXPLICIT_OFFSET, \
writebuf_off, &status1, error_code); \
......@@ -226,9 +222,8 @@ void ADIOI_LUSTRE_WriteStrided(ADIO_File fd, void *buf, int count,
writebuf_len = 0;
/* if atomicity is true, lock the region to be accessed */
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, bufsize);
}
for (j = 0; j < count; j++) {
for (i = 0; i < flat_buf->count; i++) {
......@@ -246,9 +241,8 @@ void ADIOI_LUSTRE_WriteStrided(ADIO_File fd, void *buf, int count,
ADIO_EXPLICIT_OFFSET, writebuf_off, &status1,
error_code);
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_UNLOCK(fd, start_off, SEEK_SET, bufsize);
}
if (*error_code != MPI_SUCCESS) {
ADIOI_Free(writebuf);
return;
......@@ -385,9 +379,8 @@ void ADIOI_LUSTRE_WriteStrided(ADIO_File fd, void *buf, int count,
}
/* if atomicity is true, lock the region to be accessed */
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
writebuf_off = 0;
writebuf_len = 0;
......@@ -512,14 +505,12 @@ void ADIOI_LUSTRE_WriteStrided(ADIO_File fd, void *buf, int count,
ADIO_WriteContig(fd, writebuf, writebuf_len, MPI_BYTE,
ADIO_EXPLICIT_OFFSET,
writebuf_off, &status1, error_code);
if (!(fd->atomicity)) {
if (!(fd->atomicity))
ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
}
if (*error_code != MPI_SUCCESS) return;
}
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
ADIOI_Free(writebuf);
......
......@@ -28,9 +28,9 @@ void ADIOI_NFS_ReadContig(ADIO_File fd, void *buf, int count,
MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
#endif
}
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len);
} else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len);
else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len);
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
#endif
......@@ -53,9 +53,9 @@ void ADIOI_NFS_ReadContig(ADIO_File fd, void *buf, int count,
MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
#endif
}
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len);
} else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len);
else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len);
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
#endif
......@@ -132,9 +132,9 @@ void ADIOI_NFS_ReadContig(ADIO_File fd, void *buf, int count,
readbuf_off = req_off; \
readbuf_len = (int) (ADIOI_MIN(max_bufsize, end_offset-readbuf_off+1));\
lseek(fd->fd_sys, readbuf_off, SEEK_SET);\
if (!(fd->atomicity)) {ADIOI_READ_LOCK(fd, readbuf_off, SEEK_SET, readbuf_len);} \
if (!(fd->atomicity)) ADIOI_READ_LOCK(fd, readbuf_off, SEEK_SET, readbuf_len);\
err = read(fd->fd_sys, readbuf, readbuf_len);\
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, readbuf_off, SEEK_SET, readbuf_len);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, readbuf_off, SEEK_SET, readbuf_len);\
if (err == -1) err_flag = 1; \
} \
while (req_len > readbuf_off + readbuf_len - req_off) { \
......@@ -149,9 +149,9 @@ void ADIOI_NFS_ReadContig(ADIO_File fd, void *buf, int count,
readbuf_len = (int) (partial_read + ADIOI_MIN(max_bufsize, \
end_offset-readbuf_off+1)); \
lseek(fd->fd_sys, readbuf_off+partial_read, SEEK_SET);\
if (!(fd->atomicity)) {ADIOI_READ_LOCK(fd, readbuf_off+partial_read, SEEK_SET, readbuf_len-partial_read);} \
if (!(fd->atomicity)) ADIOI_READ_LOCK(fd, readbuf_off+partial_read, SEEK_SET, readbuf_len-partial_read);\
err = read(fd->fd_sys, readbuf+partial_read, readbuf_len-partial_read);\
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, readbuf_off+partial_read, SEEK_SET, readbuf_len-partial_read);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, readbuf_off+partial_read, SEEK_SET, readbuf_len-partial_read);\
if (err == -1) err_flag = 1; \
} \
memcpy((char *)buf + userbuf_off, readbuf+req_off-readbuf_off, req_len); \
......@@ -224,9 +224,8 @@ void ADIOI_NFS_ReadStrided(ADIO_File fd, void *buf, int count,
readbuf_len = (int) (ADIOI_MIN(max_bufsize, end_offset-readbuf_off+1));
/* if atomicity is true, lock (exclusive) the region to be accessed */
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL );
......@@ -235,7 +234,7 @@ void ADIOI_NFS_ReadStrided(ADIO_File fd, void *buf, int count,
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
#endif
if (!(fd->atomicity)) {ADIOI_READ_LOCK(fd, readbuf_off, SEEK_SET, readbuf_len);}
if (!(fd->atomicity)) ADIOI_READ_LOCK(fd, readbuf_off, SEEK_SET, readbuf_len);
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
#endif
......@@ -243,7 +242,7 @@ void ADIOI_NFS_ReadStrided(ADIO_File fd, void *buf, int count,
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
#endif
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, readbuf_off, SEEK_SET, readbuf_len);}
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, readbuf_off, SEEK_SET, readbuf_len);
if (err == -1) err_flag = 1;
for (j=0; j<count; j++)
......@@ -255,9 +254,8 @@ void ADIOI_NFS_ReadStrided(ADIO_File fd, void *buf, int count,
off += flat_buf->blocklens[i];
}
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off;
......@@ -385,9 +383,8 @@ void ADIOI_NFS_ReadStrided(ADIO_File fd, void *buf, int count,
}
/* if atomicity is true, lock (exclusive) the region to be accessed */
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
/* initial read into readbuf */
readbuf_off = offset;
......@@ -401,7 +398,7 @@ void ADIOI_NFS_ReadStrided(ADIO_File fd, void *buf, int count,
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
#endif
if (!(fd->atomicity)) {ADIOI_READ_LOCK(fd, offset, SEEK_SET, readbuf_len);}
if (!(fd->atomicity)) ADIOI_READ_LOCK(fd, offset, SEEK_SET, readbuf_len);
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
#endif
......@@ -409,7 +406,7 @@ void ADIOI_NFS_ReadStrided(ADIO_File fd, void *buf, int count,
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
#endif
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, offset, SEEK_SET, readbuf_len);}
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, offset, SEEK_SET, readbuf_len);
if (err == -1) err_flag = 1;
......@@ -522,9 +519,8 @@ void ADIOI_NFS_ReadStrided(ADIO_File fd, void *buf, int count,
}
}
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off;
......
......@@ -152,11 +152,11 @@ void ADIOI_NFS_WriteContig(ADIO_File fd, void *buf, int count,
if (req_off >= writebuf_off + writebuf_len) { \
lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
err = write(fd->fd_sys, writebuf, writebuf_len); \
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
if (err == -1) err_flag = 1; \
writebuf_off = req_off; \
writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
err = read(fd->fd_sys, writebuf, writebuf_len); \
if (err == -1) { \
......@@ -172,13 +172,13 @@ void ADIOI_NFS_WriteContig(ADIO_File fd, void *buf, int count,
while (write_sz != req_len) { \
lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
err = write(fd->fd_sys, writebuf, writebuf_len); \
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
if (err == -1) err_flag = 1; \
req_len -= write_sz; \
userbuf_off += write_sz; \
writebuf_off += writebuf_len; \
writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
err = read(fd->fd_sys, writebuf, writebuf_len); \
if (err == -1) { \
......@@ -203,11 +203,11 @@ void ADIOI_NFS_WriteContig(ADIO_File fd, void *buf, int count,
MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL ); \
lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL ); \
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
MPE_Log_event( ADIOI_MPE_write_a, 0, NULL ); \
err = write(fd->fd_sys, writebuf, writebuf_len); \
MPE_Log_event( ADIOI_MPE_write_b, 0, NULL ); \
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
if (err == -1) err_flag = 1; \
writebuf_off = req_off; \
writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
......@@ -218,11 +218,11 @@ void ADIOI_NFS_WriteContig(ADIO_File fd, void *buf, int count,
MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL ); \
lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL ); \
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
MPE_Log_event( ADIOI_MPE_write_a, 0, NULL ); \
err = write(fd->fd_sys, writebuf, writebuf_len); \
MPE_Log_event( ADIOI_MPE_write_b, 0, NULL ); \
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
if (err == -1) err_flag = 1; \
req_len -= write_sz; \
userbuf_off += write_sz; \
......@@ -237,9 +237,9 @@ void ADIOI_NFS_WriteContig(ADIO_File fd, void *buf, int count,
{ \
if (req_off >= writebuf_off + writebuf_len) { \
lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
err = write(fd->fd_sys, writebuf, writebuf_len); \
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
if (err == -1) err_flag = 1; \
writebuf_off = req_off; \
writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
......@@ -248,9 +248,9 @@ void ADIOI_NFS_WriteContig(ADIO_File fd, void *buf, int count,
memcpy(writebuf+req_off-writebuf_off, (char *)buf +userbuf_off, write_sz);\
while (write_sz != req_len) { \
lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
err = write(fd->fd_sys, writebuf, writebuf_len); \
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
if (err == -1) err_flag = 1; \
req_len -= write_sz; \
userbuf_off += write_sz; \
......@@ -327,9 +327,8 @@ void ADIOI_NFS_WriteStrided(ADIO_File fd, void *buf, int count,
writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));
/* if atomicity is true, lock the region to be accessed */
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
for (j=0; j<count; j++)
for (i=0; i<flat_buf->count; i++) {
......@@ -348,7 +347,7 @@ void ADIOI_NFS_WriteStrided(ADIO_File fd, void *buf, int count,
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
#endif
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);}
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
#endif
......@@ -356,12 +355,11 @@ void ADIOI_NFS_WriteStrided(ADIO_File fd, void *buf, int count,
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_write_b, 0, NULL );
#endif
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);}
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
if (err == -1) err_flag = 1;
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
ADIOI_Free(writebuf); /* malloced in the buffered_write macro */
......@@ -488,15 +486,14 @@ void ADIOI_NFS_WriteStrided(ADIO_File fd, void *buf, int count,
}
/* if atomicity is true, lock the region to be accessed */
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
/* initial read for the read-modify-write */
writebuf_off = offset;
writebuf = (char *) ADIOI_Malloc(max_bufsize);
writebuf_len = (int)(ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);}
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL );
#endif
......@@ -638,7 +635,7 @@ void ADIOI_NFS_WriteStrided(ADIO_File fd, void *buf, int count,
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
#endif
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);}
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
#endif
......
......@@ -126,9 +126,8 @@ void ADIOI_GEN_ReadStrided(ADIO_File fd, void *buf, int count,
readbuf_len = (unsigned) (ADIOI_MIN(max_bufsize, end_offset-readbuf_off+1));
/* if atomicity is true, lock (exclusive) the region to be accessed */
if ((fd->atomicity) && ADIO_Feature(fd, ADIO_LOCKS)) {
if ((fd->atomicity) && ADIO_Feature(fd, ADIO_LOCKS))
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
ADIO_ReadContig(fd, readbuf, readbuf_len, MPI_BYTE,
ADIO_EXPLICIT_OFFSET, readbuf_off, &status1, error_code);
......@@ -145,9 +144,8 @@ void ADIOI_GEN_ReadStrided(ADIO_File fd, void *buf, int count,
}
}
if ((fd->atomicity) && ADIO_Feature(fd, ADIO_LOCKS)) {
if ((fd->atomicity) && ADIO_Feature(fd, ADIO_LOCKS))
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off;
......@@ -267,9 +265,8 @@ void ADIOI_GEN_ReadStrided(ADIO_File fd, void *buf, int count,
}
/* if atomicity is true, lock (exclusive) the region to be accessed */
if ((fd->atomicity) && ADIO_Feature(fd, ADIO_LOCKS)) {
if ((fd->atomicity) && ADIO_Feature(fd, ADIO_LOCKS))
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
readbuf_off = 0;
readbuf_len = 0;
......@@ -385,9 +382,8 @@ void ADIOI_GEN_ReadStrided(ADIO_File fd, void *buf, int count,
}
}
if ((fd->atomicity) && ADIO_Feature(fd, ADIO_LOCKS)) {
if ((fd->atomicity) && ADIO_Feature(fd, ADIO_LOCKS))
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off;
......
......@@ -14,7 +14,7 @@
if (writebuf_len) { \
ADIO_WriteContig(fd, writebuf, writebuf_len, MPI_BYTE, \
ADIO_EXPLICIT_OFFSET, writebuf_off, &status1, error_code); \
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
if (*error_code != MPI_SUCCESS) { \
*error_code = MPIO_Err_create_code(*error_code, \
MPIR_ERR_RECOVERABLE, myname, \
......@@ -25,7 +25,7 @@
} \
writebuf_off = req_off; \
writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
ADIO_ReadContig(fd, writebuf, writebuf_len, MPI_BYTE, \
ADIO_EXPLICIT_OFFSET, writebuf_off, &status1, error_code); \
if (*error_code != MPI_SUCCESS) { \
......@@ -42,7 +42,7 @@
while (write_sz != req_len) { \
ADIO_WriteContig(fd, writebuf, writebuf_len, MPI_BYTE, \
ADIO_EXPLICIT_OFFSET, writebuf_off, &status1, error_code); \
if (!(fd->atomicity)) {ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
if (*error_code != MPI_SUCCESS) { \
*error_code = MPIO_Err_create_code(*error_code, \
MPIR_ERR_RECOVERABLE, myname, \
......@@ -54,7 +54,7 @@
userbuf_off += write_sz; \
writebuf_off += writebuf_len; \
writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
if (!(fd->atomicity)) {ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);} \
if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
ADIO_ReadContig(fd, writebuf, writebuf_len, MPI_BYTE, \
ADIO_EXPLICIT_OFFSET, writebuf_off, &status1, error_code); \
if (*error_code != MPI_SUCCESS) { \
......@@ -191,9 +191,8 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, void *buf, int count,
writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize, end_offset-writebuf_off+1));
/* if atomicity is true, lock the region to be accessed */
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
for (j=0; j<count; j++)
{
......@@ -210,9 +209,8 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, void *buf, int count,
ADIO_WriteContig(fd, writebuf, writebuf_len, MPI_BYTE, ADIO_EXPLICIT_OFFSET,
writebuf_off, &status1, error_code);
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
if (*error_code != MPI_SUCCESS) return;
......@@ -336,9 +334,8 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, void *buf, int count,
}
/* if atomicity is true, lock the region to be accessed */
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
writebuf_off = 0;
writebuf_len = 0;
......@@ -460,14 +457,12 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, void *buf, int count,
if (writebuf_len) {
ADIO_WriteContig(fd, writebuf, writebuf_len, MPI_BYTE, ADIO_EXPLICIT_OFFSET,
writebuf_off, &status1, error_code);
if (!(fd->atomicity)) {
if (!(fd->atomicity))
ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
}
if (*error_code != MPI_SUCCESS) return;
}
if (fd->atomicity) {
if (fd->atomicity)
ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
}
ADIOI_Free(writebuf);
......
......@@ -664,19 +664,19 @@ int MPIOI_File_iread(MPI_File fh,
#if (defined(ROMIO_HFS) || defined(ROMIO_XFS))
# define ADIOI_WRITE_LOCK(fd, offset, whence, len) \
if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
do {if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
ADIOI_Set_lock64((fd)->fd_sys, F_SETLKW64, F_WRLCK, offset, whence, len);\
else ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_WRLCK, offset, whence, len)
else ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_WRLCK, offset, whence, len) } while (0)
# define ADIOI_READ_LOCK(fd, offset, whence, len) \
if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
do {if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
ADIOI_Set_lock64((fd)->fd_sys, F_SETLKW64, F_RDLCK, offset, whence, len);\
else ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_RDLCK, offset, whence, len)
else ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_RDLCK, offset, whence, len) while (0)
# define ADIOI_UNLOCK(fd, offset, whence, len) \
if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
do {if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
ADIOI_Set_lock64((fd)->fd_sys, F_SETLK64, F_UNLCK, offset, whence, len); \
else ADIOI_Set_lock((fd)->fd_sys, F_SETLK, F_UNLCK, offset, whence, len)
else ADIOI_Set_lock((fd)->fd_sys, F_SETLK, F_UNLCK, offset, whence, len) while (0)
#elif (defined(ROMIO_NTFS))
......
......@@ -93,16 +93,14 @@ int MPI_File_iwrite_shared(MPI_File mpi_fh, void *buf, int count,
/* to maintain strict atomicity semantics with other concurrent
operations, lock (exclusive) and call blocking routine */
if (fh->file_system != ADIO_NFS) {
if (fh->file_system != ADIO_NFS)
ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
}
ADIO_WriteContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
off, &status, &error_code);
if (fh->file_system != ADIO_NFS) {
if (fh->file_system != ADIO_NFS)
ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
}
MPIO_Completed_request_create(&fh, bufsize, &error_code, request);
}
......
......@@ -106,16 +106,14 @@ int MPI_File_read_shared(MPI_File mpi_fh, void *buf, int count,
could be a concurrent noncontiguous request. On NFS, locking
is done in the ADIO_ReadContig.*/
if ((fh->atomicity) && (fh->file_system != ADIO_NFS)) {
if ((fh->atomicity) && (fh->file_system != ADIO_NFS))
ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
}
ADIO_ReadContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
off, status, &error_code);
if ((fh->atomicity) && (fh->file_system != ADIO_NFS)) {
if ((fh->atomicity) && (fh->file_system != ADIO_NFS))
ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
}
}
else
{
......
......@@ -106,16 +106,14 @@ int MPI_File_write_shared(MPI_File mpi_fh, void *buf, int count,
could be a concurrent noncontiguous request. On NFS, locking is
done in the ADIO_WriteContig.*/
if ((fh->atomicity) && (fh->file_system != ADIO_NFS)) {
if ((fh->atomicity) && (fh->file_system != ADIO_NFS))
ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
}
ADIO_WriteContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
off, status, &error_code);
if ((fh->atomicity) && (fh->file_system != ADIO_NFS)) {
if ((fh->atomicity) && (fh->file_system != ADIO_NFS))
ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
}
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment