Revision: 14240 Author: adrian.chadd Date: Thu Jul 23 03:01:04 2009 Log: Merge r14237:14239 from /playpen/LUSCA_HEAD_store_clean_log_rework - fix rebuild-from-log logic to use buffered read/write
http://code.google.com/p/lusca-cache/source/detail?r=14240 Modified: /branches/LUSCA_HEAD /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_build_log.c ======================================= --- /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_build_log.c Wed Jul 22 07:37:20 2009 +++ /branches/LUSCA_HEAD/app/ufs_rebuild/ufs_build_log.c Thu Jul 23 03:01:04 2009 @@ -93,7 +93,7 @@ /* is it an ADD/DEL? Good. If not - count error and continue */ if (sd.op == SWAP_LOG_ADD || sd.op == SWAP_LOG_DEL) { num_valid_objects++; - if (write(1, &sd, sizeof(sd)) <= 0) { + if (fwrite(&sd, sizeof(sd), 1, stdout) != 1) { debug(47, 1) ("write failed: (%d) %s\n", errno, xstrerror()); return 0; } @@ -104,6 +104,9 @@ return 1; } + + +#define READ_BUFFER_LEN 65536 void rebuild_from_log(store_ufs_dir_t *ufs) @@ -112,12 +115,17 @@ storeSwapLogHeader hdr; int r; int version = -1; /* -1 = not set, 0 = old, 1 = new */ + char *rbuf; fp = fopen(ufs->swaplog_path, "r"); if (! fp) { perror("fopen"); return; } + + rbuf = malloc(READ_BUFFER_LEN); + if (rbuf) + setbuffer(fp, rbuf, READ_BUFFER_LEN); /* Read an entry - see if its a swap header! */ r = fread(&hdr, sizeof(hdr), 1, fp); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "lusca-commit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/lusca-commit?hl=en -~----------~----~----~----~------~----~------~--~---
