SQLite
Check-in [b02849e7bd]
Not logged in
Overview
SHA1 Hash:b02849e7bde458dd8a2d91892f18bae7fdc7724d
Date: 2012-10-05 19:10:02
User: drh
Comment:Add QNX-specific performance tweaks to the unix VFS.
Tags And Properties
Changes
hide diffs unified diffs patch

Changes to src/os_unix.c

212 unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ 212 unsigned char ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ 213 int lastErrno; /* The unix errno from last I/O error */ 213 int lastErrno; /* The unix errno from last I/O error */ 214 void *lockingContext; /* Locking style specific state */ 214 void *lockingContext; /* Locking style specific state */ 215 UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ 215 UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ 216 const char *zPath; /* Name of the file */ 216 const char *zPath; /* Name of the file */ 217 unixShm *pShm; /* Shared memory segment information */ 217 unixShm *pShm; /* Shared memory segment information */ 218 int szChunk; /* Configured by FCNTL_CHUNK_SIZE */ 218 int szChunk; /* Configured by FCNTL_CHUNK_SIZE */ > 219 #ifdef __QNXNTO__ > 220 int sectorSize; /* Device sector size */ > 221 int deviceCharacteristics; /* Precomputed device characteristics */ > 222 #endif 219 #if SQLITE_ENABLE_LOCKING_STYLE 223 #if SQLITE_ENABLE_LOCKING_STYLE 220 int openFlags; /* The flags specified at open() */ 224 int openFlags; /* The flags specified at open() */ 221 #endif 225 #endif 222 #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__) 226 #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__) 223 unsigned fsFlags; /* cached details from statfs() */ 227 unsigned fsFlags; /* cached details from statfs() */ 224 #endif 228 #endif 225 #if OS_VXWORKS 229 #if OS_VXWORKS ................................................................................................................................................................................ 3543 ** larger for some devices. 3547 ** larger for some devices. 3544 ** 3548 ** 3545 ** SQLite code assumes this function cannot fail. It also assumes that 3549 ** SQLite code assumes this function cannot fail. It also assumes that 3546 ** if two files are created in the same file-system directory (i.e. 3550 ** if two files are created in the same file-system directory (i.e. 3547 ** a database and its journal file) that the sector size will be the 3551 ** a database and its journal file) that the sector size will be the 3548 ** same for both. 3552 ** same for both. 3549 */ 3553 */ > 3554 #ifndef __QNXNTO__ 3550 static int unixSectorSize(sqlite3_file *NotUsed){ 3555 static int unixSectorSize(sqlite3_file *NotUsed){ 3551 UNUSED_PARAMETER(NotUsed); 3556 UNUSED_PARAMETER(NotUsed); 3552 return SQLITE_DEFAULT_SECTOR_SIZE; 3557 return SQLITE_DEFAULT_SECTOR_SIZE; 3553 } 3558 } > 3559 #endif 3554 3560 3555 /* 3561 /* > 3562 ** The following version of unixSectorSize() is optimized for QNX. > 3563 */ > 3564 #ifdef __QNXNTO__ > 3565 #include <sys/dcmd_blk.h> > 3566 #include <sys/statvfs.h> > 3567 static int unixSectorSize(sqlite3_file *id){ > 3568 unixFile *pFile = (unixFile*)id; > 3569 if( pFile->sectorSize == 0 ){ > 3570 struct statvfs fsInfo; > 3571 > 3572 /* Set defaults for non-supported filesystems */ > 3573 pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; > 3574 pFile->deviceCharacteristics = 0; > 3575 if( fstatvfs(pFile->h, &fsInfo) == -1 ) { > 3576 return pFile->sectorSize; > 3577 } > 3578 > 3579 if( !strcmp(fsInfo.f_basetype, "tmp") ) { > 3580 pFile->sectorSize = fsInfo.f_bsize; > 3581 pFile->deviceCharacteristics = > 3582 SQLITE_IOCAP_ATOMIC4K | /* All ram filesystem writes are atomic */ > 3583 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until > 3584 ** the write succeeds */ > 3585 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3586 ** so it is ordered */ > 3587 0; > 3588 }else if( strstr(fsInfo.f_basetype, "etfs") ){ > 3589 pFile->sectorSize = fsInfo.f_bsize; > 3590 pFile->deviceCharacteristics = > 3591 /* etfs cluster size writes are atomic */ > 3592 (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) | > 3593 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until > 3594 ** the write succeeds */ > 3595 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3596 ** so it is ordered */ > 3597 0; > 3598 }else if( !strcmp(fsInfo.f_basetype, "qnx6") ){ > 3599 pFile->sectorSize = fsInfo.f_bsize; > 3600 pFile->deviceCharacteristics = > 3601 SQLITE_IOCAP_ATOMIC | /* All filesystem writes are atomic */ > 3602 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until > 3603 ** the write succeeds */ > 3604 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3605 ** so it is ordered */ > 3606 0; > 3607 }else if( !strcmp(fsInfo.f_basetype, "qnx4") ){ > 3608 pFile->sectorSize = fsInfo.f_bsize; > 3609 pFile->deviceCharacteristics = > 3610 /* full bitset of atomics from max sector size and smaller */ > 3611 ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 | > 3612 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3613 ** so it is ordered */ > 3614 0; > 3615 }else if( strstr(fsInfo.f_basetype, "dos") ){ > 3616 pFile->sectorSize = fsInfo.f_bsize; > 3617 pFile->deviceCharacteristics = > 3618 /* full bitset of atomics from max sector size and smaller */ > 3619 ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 | > 3620 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3621 ** so it is ordered */ > 3622 0; > 3623 }else{ > 3624 pFile->deviceCharacteristics = > 3625 SQLITE_IOCAP_ATOMIC512 | /* blocks are atomic */ > 3626 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until > 3627 ** the write succeeds */ > 3628 0; > 3629 } > 3630 } > 3631 /* Last chance verification. If the sector size isn't a multiple of 512 > 3632 ** then it isn't valid.*/ > 3633 if( pFile->sectorSize % 512 != 0 ){ > 3634 pFile->deviceCharacteristics = 0; > 3635 pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; > 3636 } > 3637 return pFile->sectorSize; > 3638 } > 3639 #endif /* __QNXNTO__ */ > 3640 > 3641 /* 3556 ** Return the device characteristics for the file. This is always 0 for unix. 3642 ** Return the device characteristics for the file. This is always 0 for unix. 3557 */ 3643 */ 3558 static int unixDeviceCharacteristics(sqlite3_file *NotUsed){ | 3644 static int unixDeviceCharacteristics(sqlite3_file *id){ 3559 UNUSED_PARAMETER(NotUsed); < > 3645 #ifdef __QNXNTO__ > 3646 unixFile *p = (unixFile*)id; > 3647 if( p->sectorSize==0 ) unixSectorSize(id); > 3648 return p->deviceCharacteristics; > 3649 #else 3560 return 0; 3650 return 0; > 3651 #endif 3561 } 3652 } 3562 3653 3563 #ifndef SQLITE_OMIT_WAL 3654 #ifndef SQLITE_OMIT_WAL 3564 3655 3565 3656 3566 /* 3657 /* 3567 ** Object used to represent an shared memory buffer. 3658 ** Object used to represent an shared memory buffer.