Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nocache
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Danil Mikhailov
nocache
Commits
2ebcf516
Commit
2ebcf516
authored
Feb 04, 2012
by
Julius Plenz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fdatasync() if fd is writable
parent
ffcf68bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
Makefile
Makefile
+2
-2
fcntl_helpers.c
fcntl_helpers.c
+10
-0
nocache.c
nocache.c
+3
-0
No files found.
Makefile
View file @
2ebcf516
default
:
gcc
-Wall
-fPIC
-c
-o
nocache.o nocache.c
gcc
-Wall
-fPIC
-c
-o
f
adv_dontneed.o fadv_dontneed
.c
gcc
-Wall
-shared
-Wl
,-soname,nocache.so.1
-ldl
-o
nocache.so nocache.o f
adv_dontneed
.o
gcc
-Wall
-fPIC
-c
-o
f
cntl_helpers.o fcntl_helpers
.c
gcc
-Wall
-shared
-Wl
,-soname,nocache.so.1
-ldl
-o
nocache.so nocache.o f
cntl_helpers
.o
f
adv_dontneed
.c
→
f
cntl_helpers
.c
View file @
2ebcf516
#include <fcntl.h>
#include <unistd.h>
/* Since open() and close() are re-defined in nocache.c, it's not
* possible to include <fcntl.h> there. So we do it here. */
...
...
@@ -7,3 +8,12 @@ int fadv_dontneed(int fd, off_t offset, off_t len)
{
return
posix_fadvise
(
fd
,
offset
,
len
,
POSIX_FADV_DONTNEED
);
}
void
sync_if_writable
(
int
fd
)
{
int
r
;
if
((
r
=
fcntl
(
fd
,
F_GETFL
,
0
))
==
-
1
)
return
;
if
(
!
(
r
&
O_RDONLY
))
fdatasync
(
fd
);
}
nocache.c
View file @
2ebcf516
...
...
@@ -18,6 +18,7 @@ int close(int fd);
static
void
store_pageinfo
(
int
fd
);
static
void
free_unclaimed_pages
(
int
fd
);
extern
int
fadv_dontneed
(
int
fd
,
off_t
offset
,
off_t
len
);
extern
void
sync_if_writable
(
int
fd
);
#define _MAX_FDS 1024
...
...
@@ -141,6 +142,8 @@ static void free_unclaimed_pages(int fd)
if
(
i
==
_MAX_FDS
)
return
;
/* not found */
sync_if_writable
(
fd
);
for
(
j
=
0
;
j
<
fds
[
i
].
nr_pages
;
j
++
)
{
if
(
!
(
fds
[
i
].
info
[
j
]
&
1
))
{
fadv_dontneed
(
fd
,
j
*
PAGESIZE
,
PAGESIZE
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment