VFS FIFO: Enlarge FIFO buffer sizes
* Increase FIFO buffer capacity from 32 to 64 KiB and the FIFO atomic write size ({BUF_SIZE}) from 512 bytes to 4 KiB (both like Linux). * Fix *pathconf(..., _PC_PIPE_BUF). It was returning 4 KiB although the implemented atomic write size was 512 bytes only. Now both *pathconf() and the FIFO implementation refer to the same constant.
This commit is contained in:
parent
334ae3c73b
commit
fb52b1f8b4
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
* Distributed under the terms of the NewOS License.
|
||||
@ -8,6 +9,8 @@
|
||||
#ifndef _SYSTEM_VFS_DEFS_H
|
||||
#define _SYSTEM_VFS_DEFS_H
|
||||
|
||||
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <SupportDefs.h>
|
||||
@ -20,4 +23,18 @@ struct fd_info {
|
||||
ino_t node;
|
||||
};
|
||||
|
||||
|
||||
/* maximum write size to a pipe/FIFO that is guaranteed not to be interleaved
|
||||
with other writes (aka {PIPE_BUF}; must be >= _POSIX_PIPE_BUF) */
|
||||
#define VFS_FIFO_ATOMIC_WRITE_SIZE (4 * 1024)
|
||||
|
||||
/* pipe/FIFO buffer capacity */
|
||||
#define VFS_FIFO_BUFFER_CAPACITY (64 * 1024)
|
||||
|
||||
// make sure the constant values are sane
|
||||
#if VFS_FIFO_ATOMIC_WRITE_SIZE < _POSIX_PIPE_BUF
|
||||
# error VFS_FIFO_ATOMIC_WRITE_SIZE < _POSIX_PIPE_BUF!
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _SYSTEM_VFS_DEFS_H */
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <util/AutoLock.h>
|
||||
#include <util/ring_buffer.h>
|
||||
#include <vfs.h>
|
||||
#include <vfs_defs.h>
|
||||
#include <vm/vm.h>
|
||||
|
||||
|
||||
@ -42,11 +43,6 @@
|
||||
|
||||
|
||||
#define PIPEFS_HASH_SIZE 16
|
||||
#define PIPEFS_MAX_BUFFER_SIZE 32768
|
||||
|
||||
|
||||
// TODO: PIPE_BUF is supposed to be defined somewhere else.
|
||||
#define PIPE_BUF _POSIX_PIPE_BUF
|
||||
|
||||
|
||||
namespace fifo {
|
||||
@ -252,7 +248,7 @@ RingBuffer::CreateBuffer()
|
||||
if (fBuffer != NULL)
|
||||
return B_OK;
|
||||
|
||||
fBuffer = create_ring_buffer(PIPEFS_MAX_BUFFER_SIZE);
|
||||
fBuffer = create_ring_buffer(VFS_FIFO_BUFFER_CAPACITY);
|
||||
return fBuffer != NULL ? B_OK : B_NO_MEMORY;
|
||||
}
|
||||
|
||||
@ -376,10 +372,10 @@ Inode::WriteDataToBuffer(const void* _data, size_t* _length, bool nonBlocking)
|
||||
TRACE("Inode %p::WriteDataToBuffer(data = %p, bytes = %zu)\n", this, data,
|
||||
dataSize);
|
||||
|
||||
// According to the standard, request up to PIPE_BUF bytes shall not be
|
||||
// A request up to VFS_FIFO_ATOMIC_WRITE_SIZE bytes shall not be
|
||||
// interleaved with other writer's data.
|
||||
size_t minToWrite = 1;
|
||||
if (dataSize <= PIPE_BUF)
|
||||
if (dataSize <= VFS_FIFO_ATOMIC_WRITE_SIZE)
|
||||
minToWrite = dataSize;
|
||||
|
||||
while (dataSize > 0) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <thread_defs.h>
|
||||
#include <user_group.h>
|
||||
#include <user_timer_defs.h>
|
||||
#include <vfs_defs.h>
|
||||
|
||||
#include <errno_private.h>
|
||||
#include <libroot_private.h>
|
||||
@ -257,7 +258,7 @@ __pathconf_common(struct statvfs *fs, struct stat *st,
|
||||
return PATH_MAX;
|
||||
|
||||
case _PC_PIPE_BUF:
|
||||
return 4096;
|
||||
return VFS_FIFO_ATOMIC_WRITE_SIZE;
|
||||
|
||||
case _PC_LINK_MAX:
|
||||
return LINK_MAX;
|
||||
|
Loading…
Reference in New Issue
Block a user