Overview
| SHA1 Hash: | 63a7dd75e61afb3d05a1434f66ad6a5f08352aad |
|---|---|
| Date: | 2012-10-26 13:46:24 |
| User: | drh |
| Comment: | Add QNX-specific performance tweaks to the unix VFS. (Cherry-pick merge of b02849e7bde458.) |
Tags And Properties
- branch=trunk inherited from [704b122e53]
- sym-trunk inherited from [704b122e53]
Changes
Changes to src/os_unix.c
214 unsigned short int ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ 214 unsigned short int ctrlFlags; /* Behavioral bits. UNIXFILE_* flags */ 215 int lastErrno; /* The unix errno from last I/O error */ 215 int lastErrno; /* The unix errno from last I/O error */ 216 void *lockingContext; /* Locking style specific state */ 216 void *lockingContext; /* Locking style specific state */ 217 UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ 217 UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */ 218 const char *zPath; /* Name of the file */ 218 const char *zPath; /* Name of the file */ 219 unixShm *pShm; /* Shared memory segment information */ 219 unixShm *pShm; /* Shared memory segment information */ 220 int szChunk; /* Configured by FCNTL_CHUNK_SIZE */ 220 int szChunk; /* Configured by FCNTL_CHUNK_SIZE */ > 221 #ifdef __QNXNTO__ > 222 int sectorSize; /* Device sector size */ > 223 int deviceCharacteristics; /* Precomputed device characteristics */ > 224 #endif 221 #if SQLITE_ENABLE_LOCKING_STYLE 225 #if SQLITE_ENABLE_LOCKING_STYLE 222 int openFlags; /* The flags specified at open() */ 226 int openFlags; /* The flags specified at open() */ 223 #endif 227 #endif 224 #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__) 228 #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__) 225 unsigned fsFlags; /* cached details from statfs() */ 229 unsigned fsFlags; /* cached details from statfs() */ 226 #endif 230 #endif 227 #if OS_VXWORKS 231 #if OS_VXWORKS ................................................................................................................................................................................ 3634 ** larger for some devices. 3638 ** larger for some devices. 3635 ** 3639 ** 3636 ** SQLite code assumes this function cannot fail. It also assumes that 3640 ** SQLite code assumes this function cannot fail. It also assumes that 3637 ** if two files are created in the same file-system directory (i.e. 3641 ** if two files are created in the same file-system directory (i.e. 3638 ** a database and its journal file) that the sector size will be the 3642 ** a database and its journal file) that the sector size will be the 3639 ** same for both. 3643 ** same for both. 3640 */ 3644 */ > 3645 #ifndef __QNXNTO__ 3641 static int unixSectorSize(sqlite3_file *pFile){ | 3646 static int unixSectorSize(sqlite3_file *NotUsed){ 3642 (void)pFile; < > 3647 UNUSED_PARAMETER(NotUsed); 3643 return SQLITE_DEFAULT_SECTOR_SIZE; 3648 return SQLITE_DEFAULT_SECTOR_SIZE; 3644 } 3649 } > 3650 #endif > 3651 > 3652 /* > 3653 ** The following version of unixSectorSize() is optimized for QNX. > 3654 */ > 3655 #ifdef __QNXNTO__ > 3656 #include <sys/dcmd_blk.h> > 3657 #include <sys/statvfs.h> > 3658 static int unixSectorSize(sqlite3_file *id){ > 3659 unixFile *pFile = (unixFile*)id; > 3660 if( pFile->sectorSize == 0 ){ > 3661 struct statvfs fsInfo; > 3662 > 3663 /* Set defaults for non-supported filesystems */ > 3664 pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; > 3665 pFile->deviceCharacteristics = 0; > 3666 if( fstatvfs(pFile->h, &fsInfo) == -1 ) { > 3667 return pFile->sectorSize; > 3668 } > 3669 > 3670 if( !strcmp(fsInfo.f_basetype, "tmp") ) { > 3671 pFile->sectorSize = fsInfo.f_bsize; > 3672 pFile->deviceCharacteristics = > 3673 SQLITE_IOCAP_ATOMIC4K | /* All ram filesystem writes are atomic */ > 3674 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until > 3675 ** the write succeeds */ > 3676 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3677 ** so it is ordered */ > 3678 0; > 3679 }else if( strstr(fsInfo.f_basetype, "etfs") ){ > 3680 pFile->sectorSize = fsInfo.f_bsize; > 3681 pFile->deviceCharacteristics = > 3682 /* etfs cluster size writes are atomic */ > 3683 (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) | > 3684 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until > 3685 ** the write succeeds */ > 3686 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3687 ** so it is ordered */ > 3688 0; > 3689 }else if( !strcmp(fsInfo.f_basetype, "qnx6") ){ > 3690 pFile->sectorSize = fsInfo.f_bsize; > 3691 pFile->deviceCharacteristics = > 3692 SQLITE_IOCAP_ATOMIC | /* All filesystem writes are atomic */ > 3693 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until > 3694 ** the write succeeds */ > 3695 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3696 ** so it is ordered */ > 3697 0; > 3698 }else if( !strcmp(fsInfo.f_basetype, "qnx4") ){ > 3699 pFile->sectorSize = fsInfo.f_bsize; > 3700 pFile->deviceCharacteristics = > 3701 /* full bitset of atomics from max sector size and smaller */ > 3702 ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 | > 3703 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3704 ** so it is ordered */ > 3705 0; > 3706 }else if( strstr(fsInfo.f_basetype, "dos") ){ > 3707 pFile->sectorSize = fsInfo.f_bsize; > 3708 pFile->deviceCharacteristics = > 3709 /* full bitset of atomics from max sector size and smaller */ > 3710 ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 | > 3711 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind > 3712 ** so it is ordered */ > 3713 0; > 3714 }else{ > 3715 pFile->deviceCharacteristics = > 3716 SQLITE_IOCAP_ATOMIC512 | /* blocks are atomic */ > 3717 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until > 3718 ** the write succeeds */ > 3719 0; > 3720 } > 3721 } > 3722 /* Last chance verification. If the sector size isn't a multiple of 512 > 3723 ** then it isn't valid.*/ > 3724 if( pFile->sectorSize % 512 != 0 ){ > 3725 pFile->deviceCharacteristics = 0; > 3726 pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; > 3727 } > 3728 return pFile->sectorSize; > 3729 } > 3730 #endif /* __QNXNTO__ */ 3645 3731 3646 /* 3732 /* 3647 ** Return the device characteristics for the file. 3733 ** Return the device characteristics for the file. 3648 ** 3734 ** 3649 ** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default. 3735 ** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default. 3650 ** However, that choice is contraversial since technically the underlying 3736 ** However, that choice is contraversial since technically the underlying 3651 ** file system does not always provide powersafe overwrites. (In other 3737 ** file system does not always provide powersafe overwrites. (In other ................................................................................................................................................................................ 3654 ** very rare. And asserting PSOW makes a large reduction in the amount 3740 ** very rare. And asserting PSOW makes a large reduction in the amount 3655 ** of required I/O for journaling, since a lot of padding is eliminated. 3741 ** of required I/O for journaling, since a lot of padding is eliminated. 3656 ** Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control 3742 ** Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control 3657 ** available to turn it off and URI query parameter available to turn it off. 3743 ** available to turn it off and URI query parameter available to turn it off. 3658 */ 3744 */ 3659 static int unixDeviceCharacteristics(sqlite3_file *id){ 3745 static int unixDeviceCharacteristics(sqlite3_file *id){ 3660 unixFile *p = (unixFile*)id; 3746 unixFile *p = (unixFile*)id; > 3747 int rc = 0; > 3748 #ifdef __QNXNTO__ > 3749 if( p->sectorSize==0 ) unixSectorSize(id); > 3750 rc = p->deviceCharacteristics; > 3751 #endif 3661 if( p->ctrlFlags & UNIXFILE_PSOW ){ 3752 if( p->ctrlFlags & UNIXFILE_PSOW ){ 3662 return SQLITE_IOCAP_POWERSAFE_OVERWRITE; | 3753 rc |= SQLITE_IOCAP_POWERSAFE_OVERWRITE; 3663 }else{ < 3664 return 0; < 3665 } 3754 } > 3755 return rc; 3666 } 3756 } 3667 3757 3668 #ifndef SQLITE_OMIT_WAL 3758 #ifndef SQLITE_OMIT_WAL 3669 3759 3670 3760 3671 /* 3761 /* 3672 ** Object used to represent an shared memory buffer. 3762 ** Object used to represent an shared memory buffer.