ltp-fcntl36 偶尔出现fail unexpected data offset 20928 value 94
每次出错的都是和posix相关
先把结论说了:
fn_ofd_w和fn_ofd_r的SAFE_FCNTL参数F_OFD_SETLKW
fn_posix_w和fn_posix_r的SAFE_FCNTL参数F_SETLKW
四个函数都用的flock64结构体
case F_SETLK:
case F_SETLKW:
err = get_compat_flock(&flock, compat_ptr(arg));
case F_SETLK64:
case F_SETLKW64:
case F_OFD_SETLK:
case F_OFD_SETLKW:
err = get_compat_flock64(&flock, compat_ptr(arg));
显然posix调用get_compat_flock,传入的却是flock64
The original Linux fcntl() system call was not designed to handle large file offsets (in the flock structure).
Consequently, an fcntl64() system call was added in Linux 2.4. The newer system call employs a different structure for file locking, flock64, and corresponding commands, F_GETLK64, F_SETLK64, and F_SETLKW64. However, these details can be ignored by applications using glibc, whose fcntl() wrapper function transparently employs the more recent system call where it is available.
措施:fn_posix_w和fn_posix_r的
struct flock64 lck = {
.l_whence = SEEK_SET,
.l_start = pa->offset,
.l_len = pa->length,
.l_pid = 0,
};
改为
struct flock lck = {
.l_whence = SEEK_SET,
.l_start = pa->offset,
.l_len = pa->length,
.l_pid = 0,
};
static int thread_cnt;
static int fail_flag = 0;
static volatile int loop_flag = 1;
static const int max_thread_cnt = 32;
static const char fname[] = "tst_ofd_posix_locks"; //文件名
static const long write_size = 4096;
static pthread_barrier_t barrier;
struct param {
long offset;
long length;
long cnt;
};
thread_cnt = tst_ncpus_conf() * 3; //四核 4*3=12
if (tst_fill_file(fname, 1, write_size, thread_cnt + 1))
写4096 (4+1)次 写入fname 写入1
if (pthread_barrier_init(&barrier, NULL, thread_cnt*3) != 0)
初始化屏障结构函数,设计屏障等待的最大线程数目(4*3)
for (i = 0; i < thread_cnt; i++) {
p0[i].offset = i * write_size;
p0[i].length = write_size;
p0[i].cnt = i + 2;
p1[i].offset = i * write_size + write_size / 4;
p1[i].length = write_size;
p1[i].cnt = i + 2;
p2[i].offset = i * write_size + write_size / 2;
p2[i].length = write_size;
p2[i].cnt = i + 2;
}
P0[0]={0,4096,2}
P1[0]={1024,4096,2}
P2[0]={2048,4096,2}
P0[1]={4096,4096,3}
P1[1]={5120,4096,3}
P2[1]={6144,4096,3}
P0[2]={8192,4096,4}
P1[2]={9216,4096,4}
P2[2]={10240,4096,4}
P0[3]={12288,4096,5}
P1[3]={13312,4096,5}
P2[3]={14336,4096,5}
fail_flag = 0;
loop_flag = 1;
for (i = 0; i < thread_cnt; i++) {
SAFE_PTHREAD_CREATE(id0 + i, NULL, f0, (void *)&p0[i]);
SAFE_PTHREAD_CREATE(id1 + i, NULL, f1, (void *)&p1[i]);
SAFE_PTHREAD_CREATE(id2 + i, NULL, f2, (void *)&p2[i]);
}
static struct tcase {
void *(*fn0)(void *);
void *(*fn1)(void *);
void *(*fn2)(void *);
const char *desc;
} tcases[] = {
{fn_ofd_r, fn_ofd_w, fn_dummy, "OFD read lock vs OFD write lock"},
{fn_ofd_w, fn_posix_w, fn_dummy, "OFD write lock vs POSIX write lock"},
{fn_ofd_r, fn_posix_w, fn_dummy, "OFD read lock vs POSIX write lock"},
{fn_ofd_w, fn_posix_r, fn_dummy, "OFD write lock vs POSIX read lock"},
{fn_ofd_w, fn_ofd_w, fn_dummy, "OFD write lock vs OFD write lock"},
{fn_ofd_r, fn_ofd_w, fn_posix_w, "OFD r/w lock vs POSIX write lock"},
{fn_ofd_r, fn_ofd_w, fn_posix_r, "OFD r/w lock vs POSIX read lock"},
};
offset length cnt
建立以下线程
fn_ofd_r p00 P0[0]={0,4096,2}
fn_ofd_w p10 P1[0]={1024,4096,2}
fn_dummy p20 P2[0]={2048,4096,2}
fn_ofd_r p01 P0[1]={4096,4096,3}
fn_ofd_w p11 P1[1]={5120,4096,3}
fn_dummy p21 P2[1]={6144,4096,3}
fn_ofd_r p02 P0[2]={8192,4096,4}
fn_ofd_w p12 P1[2]={9216,4096,4}
fn_dummy p22 P2[2]={10240,4096,4}
fn_ofd_r p03 P0[3]={12288,4096,5}
fn_ofd_w p13 P1[3]={13312,4096,5}
fn_dummy p23 P2[3]={14336,4096,5}
/* OFD read lock reading data*/
static void *fn_ofd_r(void *arg)
{
struct param *pa = arg;
//pa P0[0]={0,4096,2} offset length cnt
unsigned char buf[pa->length];//4096
int i;
int fd = SAFE_OPEN(fname, O_RDWR);
struct flock64 lck = {
.l_whence = SEEK_SET,
.l_start = pa->offset,
.l_len = pa->length,
.l_pid = 0,
};
while (loop_flag) {
memset(buf, 0, pa->length);
lck.l_type = F_RDLCK;
SAFE_FCNTL(fd, F_OFD_SETLKW, &lck);
/* rlock acquired */
SAFE_LSEEK(fd, pa->offset, SEEK_SET);
SAFE_READ(1, fd, buf, pa->length);
/* Verifying data read */
for (i = 0; i < pa->length; i++) {
//buf的值介于1-254之间
if (buf[i] < 1 || buf[i] > 254) {
tst_res(TFAIL, "Unexpected data "
"offset %ld value %d",
pa->offset + i, buf[i]);
fail_flag = 1;
break;
}
//buf 1024字节之内的数值应该一致,除法取整
int j = (i / (pa->length/4)) * pa->length/4;
if (buf[i] != buf[j]) {
tst_res(TFAIL, "Unexpected data "
"offset %ld value %d",
pa->offset + i, buf[i]);
fail_flag = 1;
break;
}
}
lck.l_type = F_UNLCK;
SAFE_FCNTL(fd, F_OFD_SETLK, &lck);
sched_yield();
}
pthread_barrier_wait(&barrier);
SAFE_CLOSE(fd);
return NULL;
}
/* OFD write lock writing data*/
static void *fn_ofd_w(void *arg)
{
struct param *pa = arg;
//pa P1[0]={1024,4096,2} offset length cnt
unsigned char buf[pa->length];
int fd = SAFE_OPEN(fname, O_RDWR);
long wt = pa->cnt;
struct flock64 lck = {
.l_whence = SEEK_SET,
.l_start = pa->offset,
.l_len = pa->length,
.l_pid = 0,
};
while (loop_flag) {
memset(buf, wt, pa->length);
lck.l_type = F_WRLCK;
SAFE_FCNTL(fd, F_OFD_SETLKW, &lck);
SAFE_LSEEK(fd, pa->offset, SEEK_SET);
SAFE_WRITE(1, fd, buf, pa->length);
lck.l_type = F_UNLCK;
SAFE_FCNTL(fd, F_OFD_SETLKW, &lck);
wt++;
if (wt >= 255)
wt = pa->cnt;
sched_yield();
}
pthread_barrier_wait(&barrier);
SAFE_CLOSE(fd);
return NULL;
}
//啥也不干
static void *fn_dummy(void *arg)
{
arg = NULL;
pthread_barrier_wait(&barrier);
return arg;
}
ltp-fcntl36 偶尔出现fail unexpected data offset 20928 value 94的更多相关文章
- linux内核启动时报错ubi0 error: validate_ec_hdr: bad data offset 256, expected 128
1.错误解析 ubi的EC header中有一个字段data_offset来记录数据偏移,数据偏移必须正确才能正确读取每一个物理擦除块中的数据 2.解决方法 擦除整块flash,然后再重新烧写包含ub ...
- [转贴]LTP--linux稳定性测试 linux性能测试 ltp压力测试 ---IBM 的 linux test project
https://blog.csdn.net/melody157398/article/details/24354415 LTP--linux稳定性测试 linux性能测试 ltp压力测试 ---I ...
- LTP(LinuxTest Project)测试工具
LTP(LinuxTest Project)是SGI.IBM.OSDL和Bull合作的项目,目的是为开源社区提供一个测试套件,用来验证Linux系统可靠性.健壮性和稳定性.LTP测试套件是测试Linu ...
- LTP--linux稳定性测试 linux性能测试 ltp压力测试 ---IBM 的 linux test project
LTP--linux稳定性测试 linux性能测试 ltp压力测试 ---IBM 的 linux test project Peter盼 2014-04-23 11:25:49 20302 收藏 ...
- LTP--linux稳定性测试 linux性能测试 ltp压力测试 内核更新 稳定性测试
LTP--linux稳定性测试 linux性能测试 ltp压力测试 zhangzj1030关注14人评论33721人阅读2011-12-09 12:07:45 说明:在写这篇文章之前,本人也不曾了 ...
- LTP--linux稳定性测试 linux性能测试 ltp压力测试 ltp-pan
LTP--linux稳定性测试 linux性能测试 ltp压力测试 zhangzj1030关注14人评论33710人阅读2011-12-09 12:07:45 说明:在写这篇文章之前,本人也不曾了 ...
- LTP介绍
1.LTP介绍 LTP--linut test project ,ltp套件是由Linux Test Project所开发的一套系统測试套件.它基于系统资源的利用率统计开发了一个測试的组合,为系 ...
- Offset Management For Apache Kafka With Apache Spark Streaming
An ingest pattern that we commonly see being adopted at Cloudera customers is Apache Spark Streaming ...
- kafka使用getOffsetsBefore()获取获取offset异常分析
根据时间戳获取kafka的topic的偏移量,结果获取的偏移量量数据组的长度为0,就会出现如下的数组下标越界的异常,实现的原理是使用了kafka的getOffsetsBefore()方法: Excep ...
随机推荐
- vue 上传图片 input=file
一.逻辑 点击li触发事件chooseImage 即触发input标签事件photoChange input标签事件photoChange file返回的是如下变量 模拟上传表单方法 执行上传 二.代 ...
- Centos7下ups监控apcupsd的使用
什么是UPS UPS-Uninterrupted Power System:利用电池化学能作为后备能量,在市电断电等电网故障时,不间断地为用户设备提供(交流)电能的一种能量转换装置. UPS的主要功能 ...
- css实现右侧固定宽度,左侧宽度自适应
https://blog.csdn.net/qq_22889599/article/details/78414040 反过来也可以:左侧宽度固定,右侧自适应.不管是左是右,反正就是一边宽度固定,一边宽 ...
- [django]详情页列表页
详情页列表页 列表页展示titile--这个模型的部分字段 详情页展示这个模型的所有字段 我想看下related_name这个从主表取子表数据 取数据--官网投票例子 https://docs.dja ...
- (转)以太坊(Ethereum)全零地址(0x000000...)揭秘
最近,一位小伙伴向我咨询问题,说他发现了一个诡异的现象.以太坊的区块链中居然有全是0的地址:0x0000000000000000000000000000000000000000 这究竟是怎么回事儿呢? ...
- Linux下搭建redis服务器
1.redis需要gcc的编译环境,在线安装gcc:# yum install gcc-c++ 2.上传redis的压缩包到Linux系统,解压 3.进入源码目录,编译(注意要有makefile), ...
- zabbix 监控 redis
redis 可以直接使用zabbix官方的模板 模板地址: https://github.com/blacked/zbx_redis_template redis 主机通过脚本把数据推送到zabbi ...
- gem安装出错了
1.首先是SSL出错. SSL 证书错误 正常情况下,你是不会遇到 SSL 证书错误的,除非你的 Ruby 安装方式不正确. 如果遇到 SSL 证书问题,你又无法解决,请修改 ~/.gemrc 文件, ...
- vue2.3时使用手机调试,提示媒体已断开的解决方案
参考链接:http://www.xitonghe.com/jiaocheng/windows7-9623.html 1.在当前版本vue下开发,发现只能在localhost时调试,不能使用电脑的ip, ...
- Selenium基本使用(十三)测试中常见问题
我们在使用selenium测试过程中,经常会遇到这样的问题: 1.frame或iframe <iframe id='frame1' name='frame1'> <input typ ...