* [PATCH 3/5] f2fs: clear_bit the SSR selected section in the victim_secmap
From: Yunlong Song @ 2018-07-23 14:10 UTC (permalink / raw)
To: jaegeuk, chao, yuchao0, yunlong.song, yunlong.song
Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
linux-kernel
In-Reply-To: <1532355022-163029-1-git-send-email-yunlong.song@huawei.com>
SSR uses get_victim to select ssr segment to allocate data blocks, which
makes the previous result of victim_secmap inaccurately, so we would
better clear the bit of the section in the victim_secmap.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
fs/f2fs/gc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 705d419..0e7a265 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -394,7 +394,8 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
set_bit(secno, dirty_i->victim_secmap);
sbi->cur_bg_victim_sec = secno;
}
- }
+ } else
+ clear_bit(secno, dirty_i->victim_secmap);
*result = (p.min_segno / p.ofs_unit) * p.ofs_unit;
trace_f2fs_get_victim(sbi->sb, type, gc_type, &p,
--
1.8.5.2
^ permalink raw reply related
* [PATCH 2/5] f2fs: add cur_victim_sec for BG_GC to avoid skipping BG_GC victim
From: Yunlong Song @ 2018-07-23 14:10 UTC (permalink / raw)
To: jaegeuk, chao, yuchao0, yunlong.song, yunlong.song
Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
linux-kernel
In-Reply-To: <1532355022-163029-1-git-send-email-yunlong.song@huawei.com>
If f2fs aborts BG_GC, then the section bit of victim_secmap will be set,
which will cause the section skipped in the future get_victim of BG_GC.
In a worst case that each section in the victim_secmap is set and there
are enough free sections (so FG_GC can not be triggered), then BG_GC
will skip all the sections and cannot find any victims, causing BG_GC
failed each time. Besides, SSR also uses BG_GC to get ssr segment, if
many sections in the victim_secmap are set, then SSR cannot get a proper
ssr segment to allocate blocks, which makes SSR inefficiently. To fix
this problem, we can add cur_victim_sec for BG_GC similar like that in
FG_GC to avoid selecting the same section repeatedly.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
fs/f2fs/f2fs.h | 3 ++-
fs/f2fs/gc.c | 15 +++++++++------
fs/f2fs/segment.h | 3 ++-
fs/f2fs/super.c | 3 ++-
include/trace/events/f2fs.h | 18 ++++++++++++------
5 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 57a8851..f8a7b42 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1217,7 +1217,8 @@ struct f2fs_sb_info {
/* for cleaning operations */
struct mutex gc_mutex; /* mutex for GC */
struct f2fs_gc_kthread *gc_thread; /* GC thread */
- unsigned int cur_victim_sec; /* current victim section num */
+ unsigned int cur_fg_victim_sec; /* current FG_GC victim section num */
+ unsigned int cur_bg_victim_sec; /* current BG_GC victim section num */
unsigned int gc_mode; /* current GC state */
/* for skip statistic */
unsigned long long skipped_atomic_files[2]; /* FG_GC and BG_GC */
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 2ba470d..705d419 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -367,8 +367,6 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
if (sec_usage_check(sbi, secno))
goto next;
- if (gc_type == BG_GC && test_bit(secno, dirty_i->victim_secmap))
- goto next;
cost = get_gc_cost(sbi, segno, &p);
@@ -391,14 +389,17 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
if (p.alloc_mode == LFS) {
secno = GET_SEC_FROM_SEG(sbi, p.min_segno);
if (gc_type == FG_GC)
- sbi->cur_victim_sec = secno;
- else
+ sbi->cur_fg_victim_sec = secno;
+ else {
set_bit(secno, dirty_i->victim_secmap);
+ sbi->cur_bg_victim_sec = secno;
+ }
}
*result = (p.min_segno / p.ofs_unit) * p.ofs_unit;
trace_f2fs_get_victim(sbi->sb, type, gc_type, &p,
- sbi->cur_victim_sec,
+ sbi->cur_fg_victim_sec,
+ sbi->cur_bg_victim_sec,
prefree_segments(sbi), free_segments(sbi));
}
out:
@@ -1098,7 +1099,9 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
}
if (gc_type == FG_GC)
- sbi->cur_victim_sec = NULL_SEGNO;
+ sbi->cur_fg_victim_sec = NULL_SEGNO;
+ else
+ sbi->cur_bg_victim_sec = NULL_SEGNO;
if (!sync) {
if (has_not_enough_free_secs(sbi, sec_freed, 0)) {
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 5049551..b21bb96 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -787,7 +787,8 @@ static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type)
static inline bool sec_usage_check(struct f2fs_sb_info *sbi, unsigned int secno)
{
- if (IS_CURSEC(sbi, secno) || (sbi->cur_victim_sec == secno))
+ if (IS_CURSEC(sbi, secno) || (sbi->cur_fg_victim_sec == secno) ||
+ (sbi->cur_bg_victim_sec == secno))
return true;
return false;
}
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 7187885..ef69ebf 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2386,7 +2386,8 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
sbi->root_ino_num = le32_to_cpu(raw_super->root_ino);
sbi->node_ino_num = le32_to_cpu(raw_super->node_ino);
sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino);
- sbi->cur_victim_sec = NULL_SECNO;
+ sbi->cur_fg_victim_sec = NULL_SECNO;
+ sbi->cur_bg_victim_sec = NULL_SECNO;
sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
sbi->dir_level = DEF_DIR_LEVEL;
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 7956989..0f01f82 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -693,10 +693,12 @@
TRACE_EVENT(f2fs_get_victim,
TP_PROTO(struct super_block *sb, int type, int gc_type,
- struct victim_sel_policy *p, unsigned int pre_victim,
+ struct victim_sel_policy *p, unsigned int pre_fg_victim,
+ unsigned int pre_bg_victim,
unsigned int prefree, unsigned int free),
- TP_ARGS(sb, type, gc_type, p, pre_victim, prefree, free),
+ TP_ARGS(sb, type, gc_type, p, pre_fg_victim, pre_bg_victim,
+ prefree, free),
TP_STRUCT__entry(
__field(dev_t, dev)
@@ -707,7 +709,8 @@
__field(unsigned int, victim)
__field(unsigned int, cost)
__field(unsigned int, ofs_unit)
- __field(unsigned int, pre_victim)
+ __field(unsigned int, pre_fg_victim)
+ __field(unsigned int, pre_bg_victim)
__field(unsigned int, prefree)
__field(unsigned int, free)
),
@@ -721,14 +724,16 @@
__entry->victim = p->min_segno;
__entry->cost = p->min_cost;
__entry->ofs_unit = p->ofs_unit;
- __entry->pre_victim = pre_victim;
+ __entry->pre_fg_victim = pre_fg_victim;
+ __entry->pre_bg_victim = pre_bg_victim;
__entry->prefree = prefree;
__entry->free = free;
),
TP_printk("dev = (%d,%d), type = %s, policy = (%s, %s, %s), "
"victim = %u, cost = %u, ofs_unit = %u, "
- "pre_victim_secno = %d, prefree = %u, free = %u",
+ "pre_fg_victim_secno = %d, pre_bg_victim_secno = %d, "
+ "prefree = %u, free = %u",
show_dev(__entry->dev),
show_data_type(__entry->type),
show_gc_type(__entry->gc_type),
@@ -737,7 +742,8 @@
__entry->victim,
__entry->cost,
__entry->ofs_unit,
- (int)__entry->pre_victim,
+ (int)__entry->pre_fg_victim,
+ (int)__entry->pre_bg_victim,
__entry->prefree,
__entry->free)
);
--
1.8.5.2
^ permalink raw reply related
* [PATCH 1/5] f2fs: clear victim_secmap when section has full valid blocks
From: Yunlong Song @ 2018-07-23 14:10 UTC (permalink / raw)
To: jaegeuk, chao, yuchao0, yunlong.song, yunlong.song
Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
linux-kernel
In-Reply-To: <1532355022-163029-1-git-send-email-yunlong.song@huawei.com>
Without this patch, f2fs only clears victim_secmap when it finds out
that the section has no valid blocks at all, but forgets to clear the
victim_secmap when the whole section has full valid blocks.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
fs/f2fs/segment.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index cfff7cf..255bff5 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -776,7 +776,9 @@ static void __remove_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
if (test_and_clear_bit(segno, dirty_i->dirty_segmap[t]))
dirty_i->nr_dirty[t]--;
- if (get_valid_blocks(sbi, segno, true) == 0)
+ if (get_valid_blocks(sbi, segno, true) == 0 ||
+ get_valid_blocks(sbi, segno, true) ==
+ (sbi->segs_per_sec << sbi->log_blocks_per_seg))
clear_bit(GET_SEC_FROM_SEG(sbi, segno),
dirty_i->victim_secmap);
}
--
1.8.5.2
^ permalink raw reply related
* [PATCH 0/5] f2fs: fix and improve for victim_secmap
From: Yunlong Song @ 2018-07-23 14:10 UTC (permalink / raw)
To: jaegeuk, chao, yuchao0, yunlong.song, yunlong.song
Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
linux-kernel
There are some fixes and improvements for using with victim_secmap.
Yunlong Song (5):
f2fs: clear victim_secmap when section has full valid blocks
f2fs: add cur_victim_sec for BG_GC to avoid skipping BG_GC victim
f2fs: clear_bit the SSR selected section in the victim_secmap
f2fs: let BG_GC check every dirty segments and gc over a threshold
f2fs: add proc entry to show victim_secmap bitmap
fs/f2fs/f2fs.h | 5 ++++-
fs/f2fs/gc.c | 39 ++++++++++++++++++++++++++++++---------
fs/f2fs/segment.c | 4 +++-
fs/f2fs/segment.h | 12 +++++++++++-
fs/f2fs/super.c | 3 ++-
fs/f2fs/sysfs.c | 25 +++++++++++++++++++++++++
include/trace/events/f2fs.h | 18 ++++++++++++------
7 files changed, 87 insertions(+), 19 deletions(-)
--
1.8.5.2
^ permalink raw reply
* Re: [PATCH 0/3] PTI for x86-32 Fixes and Updates
From: Pavel Machek @ 2018-07-23 14:09 UTC (permalink / raw)
To: Joerg Roedel
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, x86, linux-kernel,
linux-mm, Linus Torvalds, Andy Lutomirski, Dave Hansen,
Josh Poimboeuf, Juergen Gross, Peter Zijlstra, Borislav Petkov,
Jiri Kosina, Boris Ostrovsky, Brian Gerst, David Laight,
Denys Vlasenko, Eduardo Valentin, Greg KH, Will Deacon, aliguori,
daniel.gruss, hughd, keescook, Andrea Arcangeli, Waiman Long,
David H . Gutteridge, jroedel, Arnaldo Carvalho de Melo,
Alexander Shishkin, Jiri Olsa, Namhyung Kim
In-Reply-To: <1532103744-31902-1-git-send-email-joro@8bytes.org>
[-- Attachment #1: Type: text/plain, Size: 2489 bytes --]
Hi!
> here are 3 patches which update the PTI-x86-32 patches recently merged
> into the tip-tree. The patches are ordered by importance:
It seems PTI is now in -next. I'll test that soon.
Meanwhile... it looks like gcc is not slowed down significantly, but
other stuff sees 30% .. 40% slowdowns... which is rather
significant.
Would it be possible to have per-process control of kpti? I have
some processes where trading of speed for security would make sense.
Best regards,
Pavel
cd ~/g/tui/nowcast
time ./nowcast -x (30%)
KPTI: 139.25user 73.65system 269.90 (4m29.901s) elapsed 78.88%CPU
133.35user 73.15system 228.80 (3m48.802s) elapsed 90.25%CPU
140.51user 74.21system 218.33 (3m38.338s) elapsed 98.34%CPU
133.85user 75.89system 212.02 (3m32.026s) elapsed 98.93%CPU (no chromium)
139.34user 75.00system 235.75 (3m55.752s) elapsed 90.92%CPU
4.18: 116.99user 43.79system 217.65 (3m37.653s) elapsed 73.87%CPU
115.14user 43.97system 178.85 (2m58.855s) elapsed 88.96%CPU
128.47user 47.22system 178.24 (2m58.245s) elapsed 98.57%CPU
132.30user 49.27system 184.40 (3m4.408s) elapsed 98.46%CPU
134.88user 48.59system 186.67 (3m6.673s) elapsed 98.29%CPU
132.15user 48.65system 524.68 (8m44.684s) elapsed 34.46%CPU
120.38user 45.45system 168.72 (2m48.720s) elapsed 98.29%CPU
time cat /dev/urandom | head -c 10000000 | bzip2 -9 - | wc -c (40%)
v4.18: 4.57user 0.23system 4.64 (0m4.644s) elapsed 103.53%CPU
4.86user 0.23system 4.95 (0m4.952s) elapsed 102.81%CPU
5.13user 0.22system 5.19 (0m5.190s) elapsed 103.14%CPU
KPTI: 6.39user 0.48system 6.74 (0m6.747s) elapsed 101.96%CPU
6.66user 0.41system 6.91 (0m6.912s) elapsed 102.51%CPU
6.53user 0.51system 6.91 (0m6.919s) elapsed 101.99%CPU
v4l-utils: make clean, time make
v4.18: 191.93user 11.00system 211.19 (3m31.191s) elapsed 96.09%CPU
221.21user 14.69system 248.73 (4m8.734s) elapsed 94.84%CPU
198.35user 11.61system 211.39 (3m31.392s) elapsed 99.32%CPU
204.87user 11.69system 217.97 (3m37.971s) elapsed 99.35%CPU
203.68user 11.88system 217.29 (3m37.291s) elapsed 99.20%CPU
KPTI: 156.45user 40.08system 204.77 (3m24.777s) elapsed 95.97%CPU
183.32user 38.64system 225.03 (3m45.031s) elapsed 98.63%CPU
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply
* Re: [PATCH] drm/atomic: Initialize variables in drm_atomic_helper_async_check() to make gcc happy
From: Sean Paul @ 2018-07-23 14:09 UTC (permalink / raw)
To: Boris Brezillon; +Cc: David Airlie, dri-devel
In-Reply-To: <20180723135902.26037-1-boris.brezillon@bootlin.com>
On Mon, Jul 23, 2018 at 03:59:02PM +0200, Boris Brezillon wrote:
> drm_atomic_helper_async_check() declares the plane, old_plane_state and
> new_plane_state variables to iterate over all planes of the atomic
> state and make sure only one plane is enabled.
>
> Unfortunately gcc is not smart enough to figure out that the check on
> n_planes is enough to guarantee that plane, new_plane_state and
> old_plane_state are initialized.
>
> Explicitly initialized those variables to NULL to make gcc happy.
Reviewed-by: Sean Paul <seanpaul@chromium.org>
>
> Fixes: fef9df8b5945 ("drm/atomic: initial support for asynchronous plane update")
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
> drivers/gpu/drm/drm_atomic_helper.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index f7ccfebd3ca8..80be74df7ba6 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1538,8 +1538,9 @@ int drm_atomic_helper_async_check(struct drm_device *dev,
> {
> struct drm_crtc *crtc;
> struct drm_crtc_state *crtc_state;
> - struct drm_plane *plane;
> - struct drm_plane_state *old_plane_state, *new_plane_state;
> + struct drm_plane *plane = NULL;
> + struct drm_plane_state *old_plane_state = NULL;
> + struct drm_plane_state *new_plane_state = NULL;
> const struct drm_plane_helper_funcs *funcs;
> int i, n_planes = 0;
>
> --
> 2.14.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply
* [PATCH] bpf: Add Python 3 support to selftests scripts for bpf
From: Jeremy Cline @ 2018-07-23 14:08 UTC (permalink / raw)
To: Daniel Borkmann, Alexei Starovoitov, Shuah Khan
Cc: netdev, linux-kernel, linux-kselftest, Lawrence Brakmo,
jakub.kicinski
In-Reply-To: <1aa3dc98-2ab1-7386-d5d9-afd3dbb3fde9@iogearbox.net>
Hi Daniel,
On 07/20/2018 04:45 PM, Daniel Borkmann wrote:
> On 07/18/2018 11:36 PM, Jeremy Cline wrote:
>> Adjust tcp_client.py and tcp_server.py to work with Python 3 by using
>> the print function, marking string literals as bytes, and using the
>> newer exception syntax. This should be functionally equivalent and
>> support Python 2.6 through Python 3.7.
>>
>> Signed-off-by: Jeremy Cline <jcline@redhat.com>
>
> Thanks for the patch, Jeremy! Given we also have test_offload.py in BPF
> kselftests and it is written for python 3 only, it would probably make
> sense to adapt the tcp_{client,server}.py towards python 3 as well, so
> we wouldn't need to keep extra compat for 2 and have a consistent version
> dependency. Lawrence / Jeremy, any objections?
I certainly don't object to Python 3 only and I'm happy to drop the
Python 2 compatibility from this patch if that's okay.
>
>> tools/testing/selftests/bpf/tcp_client.py | 12 ++++++------
>> tools/testing/selftests/bpf/tcp_server.py | 17 +++++++++--------
>> 2 files changed, 15 insertions(+), 14 deletions(-)
>>
>> diff --git a/tools/testing/selftests/bpf/tcp_client.py b/tools/testing/selftests/bpf/tcp_client.py
>> index 481dccdf140c..9fe5f1b5c020 100755
>> --- a/tools/testing/selftests/bpf/tcp_client.py
>> +++ b/tools/testing/selftests/bpf/tcp_client.py
>> @@ -1,4 +1,4 @@
>> -#!/usr/bin/env python2
>> +#!/usr/bin/env python
>> #
>> # SPDX-License-Identifier: GPL-2.0
>> #
>> @@ -9,11 +9,11 @@ import subprocess
>> import select
>>
>> def read(sock, n):
>> - buf = ''
>> + buf = b''
>> while len(buf) < n:
>> rem = n - len(buf)
>> try: s = sock.recv(rem)
>> - except (socket.error), e: return ''
>> + except (socket.error) as e: return b''
>> buf += s
>> return buf
>>
>> @@ -22,7 +22,7 @@ def send(sock, s):
>> count = 0
>> while count < total:
>> try: n = sock.send(s)
>> - except (socket.error), e: n = 0
>> + except (socket.error) as e: n = 0
>> if n == 0:
>> return count;
>> count += n
>> @@ -39,10 +39,10 @@ try:
>> except socket.error as e:
>> sys.exit(1)
>>
>> -buf = ''
>> +buf = b''
>> n = 0
>> while n < 1000:
>> - buf += '+'
>> + buf += b'+'
>> n += 1
>>
>> sock.settimeout(1);
>> diff --git a/tools/testing/selftests/bpf/tcp_server.py b/tools/testing/selftests/bpf/tcp_server.py
>> index bc454d7d0be2..1d4a40a6584b 100755
>> --- a/tools/testing/selftests/bpf/tcp_server.py
>> +++ b/tools/testing/selftests/bpf/tcp_server.py
>> @@ -1,7 +1,8 @@
>> -#!/usr/bin/env python2
>> +#!/usr/bin/env python
>> #
>> # SPDX-License-Identifier: GPL-2.0
>> #
>> +from __future__ import print_function
>>
>> import sys, os, os.path, getopt
>> import socket, time
>> @@ -9,11 +10,11 @@ import subprocess
>> import select
>>
>> def read(sock, n):
>> - buf = ''
>> + buf = b''
>> while len(buf) < n:
>> rem = n - len(buf)
>> try: s = sock.recv(rem)
>> - except (socket.error), e: return ''
>> + except (socket.error) as e: return b''
>> buf += s
>> return buf
>>
>> @@ -22,7 +23,7 @@ def send(sock, s):
>> count = 0
>> while count < total:
>> try: n = sock.send(s)
>> - except (socket.error), e: n = 0
>> + except (socket.error) as e: n = 0
>> if n == 0:
>> return count;
>> count += n
>> @@ -43,7 +44,7 @@ host = socket.gethostname()
>>
>> try: serverSocket.bind((host, 0))
>> except socket.error as msg:
>> - print 'bind fails: ', msg
>> + print('bind fails: ' + str(msg))
>>
>> sn = serverSocket.getsockname()
>> serverPort = sn[1]
>> @@ -51,10 +52,10 @@ serverPort = sn[1]
>> cmdStr = ("./tcp_client.py %d &") % (serverPort)
>> os.system(cmdStr)
>>
>> -buf = ''
>> +buf = b''
>> n = 0
>> while n < 500:
>> - buf += '.'
>> + buf += b'.'
>> n += 1
>>
>> serverSocket.listen(MAX_PORTS)
>> @@ -79,5 +80,5 @@ while True:
>> serverSocket.close()
>> sys.exit(0)
>> else:
>> - print 'Select timeout!'
>> + print('Select timeout!')
>> sys.exit(1)
>>
>
^ permalink raw reply
* [U-Boot] [PATCH] fs: ext4: Prevent erasing buffer past file size
From: Tom Rini @ 2018-07-23 14:09 UTC (permalink / raw)
To: u-boot
In-Reply-To: <20180723094212.3031-1-marex@denx.de>
On Mon, Jul 23, 2018 at 11:42:12AM +0200, Marek Vasut wrote:
> The variable 'n' represents the number of bytes to be read from a certain
> offset in a file, to a certain offset in buffer 'buf'. The variable 'len'
> represents the length of the entire file, clamped correctly to avoid any
> overflows.
>
> Therefore, comparing 'n' and 'len' to determine whether clearing 'n'
> bytes of the buffer 'buf' at a certain offset would clear data past
> buffer 'buf' cannot lead to a correct result, since the 'n' does not
> contain the offset from the beginning of the file.
>
> This patch keeps track of the amount of data read and checks for the
> buffer overflow by comparing the 'n' to the remaining amount of data
> to be read instead.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Ian Ray <ian.ray@ge.com>
> Cc: Martyn Welch <martyn.welch@collabora.co.uk>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> Fixes: ecdfb4195b20 ("ext4: recover from filesystem corruption when reading")
Good catch. Can this problem also be recreated/tested with
test/fs/fs-test.sh? Thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180723/3ac24264/attachment.sig>
^ permalink raw reply
* Re: [Qemu-devel] [PATCH] block/vvfat: Disable debug message by default
From: Kevin Wolf @ 2018-07-23 14:08 UTC (permalink / raw)
To: Thomas Huth; +Cc: qemu-block, Max Reitz, qemu-devel
In-Reply-To: <1531926509-8280-1-git-send-email-thuth@redhat.com>
Am 18.07.2018 um 17:08 hat Thomas Huth geschrieben:
> It's annoying to see this debug message every time you use vvfat.
> Disable it with the DLOG() macro by default, as it is done with the
> other debug messages in this file.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply
* [PATCH] bpf: Add Python 3 support to selftests scripts for bpf
From: Jeremy Cline @ 2018-07-23 14:08 UTC (permalink / raw)
In-Reply-To: <1aa3dc98-2ab1-7386-d5d9-afd3dbb3fde9@iogearbox.net>
Hi Daniel,
On 07/20/2018 04:45 PM, Daniel Borkmann wrote:
> On 07/18/2018 11:36 PM, Jeremy Cline wrote:
>> Adjust tcp_client.py and tcp_server.py to work with Python 3 by using
>> the print function, marking string literals as bytes, and using the
>> newer exception syntax. This should be functionally equivalent and
>> support Python 2.6 through Python 3.7.
>>
>> Signed-off-by: Jeremy Cline <jcline at redhat.com>
>
> Thanks for the patch, Jeremy! Given we also have test_offload.py in BPF
> kselftests and it is written for python 3 only, it would probably make
> sense to adapt the tcp_{client,server}.py towards python 3 as well, so
> we wouldn't need to keep extra compat for 2 and have a consistent version
> dependency. Lawrence / Jeremy, any objections?
I certainly don't object to Python 3 only and I'm happy to drop the
Python 2 compatibility from this patch if that's okay.
>
>> tools/testing/selftests/bpf/tcp_client.py | 12 ++++++------
>> tools/testing/selftests/bpf/tcp_server.py | 17 +++++++++--------
>> 2 files changed, 15 insertions(+), 14 deletions(-)
>>
>> diff --git a/tools/testing/selftests/bpf/tcp_client.py b/tools/testing/selftests/bpf/tcp_client.py
>> index 481dccdf140c..9fe5f1b5c020 100755
>> --- a/tools/testing/selftests/bpf/tcp_client.py
>> +++ b/tools/testing/selftests/bpf/tcp_client.py
>> @@ -1,4 +1,4 @@
>> -#!/usr/bin/env python2
>> +#!/usr/bin/env python
>> #
>> # SPDX-License-Identifier: GPL-2.0
>> #
>> @@ -9,11 +9,11 @@ import subprocess
>> import select
>>
>> def read(sock, n):
>> - buf = ''
>> + buf = b''
>> while len(buf) < n:
>> rem = n - len(buf)
>> try: s = sock.recv(rem)
>> - except (socket.error), e: return ''
>> + except (socket.error) as e: return b''
>> buf += s
>> return buf
>>
>> @@ -22,7 +22,7 @@ def send(sock, s):
>> count = 0
>> while count < total:
>> try: n = sock.send(s)
>> - except (socket.error), e: n = 0
>> + except (socket.error) as e: n = 0
>> if n == 0:
>> return count;
>> count += n
>> @@ -39,10 +39,10 @@ try:
>> except socket.error as e:
>> sys.exit(1)
>>
>> -buf = ''
>> +buf = b''
>> n = 0
>> while n < 1000:
>> - buf += '+'
>> + buf += b'+'
>> n += 1
>>
>> sock.settimeout(1);
>> diff --git a/tools/testing/selftests/bpf/tcp_server.py b/tools/testing/selftests/bpf/tcp_server.py
>> index bc454d7d0be2..1d4a40a6584b 100755
>> --- a/tools/testing/selftests/bpf/tcp_server.py
>> +++ b/tools/testing/selftests/bpf/tcp_server.py
>> @@ -1,7 +1,8 @@
>> -#!/usr/bin/env python2
>> +#!/usr/bin/env python
>> #
>> # SPDX-License-Identifier: GPL-2.0
>> #
>> +from __future__ import print_function
>>
>> import sys, os, os.path, getopt
>> import socket, time
>> @@ -9,11 +10,11 @@ import subprocess
>> import select
>>
>> def read(sock, n):
>> - buf = ''
>> + buf = b''
>> while len(buf) < n:
>> rem = n - len(buf)
>> try: s = sock.recv(rem)
>> - except (socket.error), e: return ''
>> + except (socket.error) as e: return b''
>> buf += s
>> return buf
>>
>> @@ -22,7 +23,7 @@ def send(sock, s):
>> count = 0
>> while count < total:
>> try: n = sock.send(s)
>> - except (socket.error), e: n = 0
>> + except (socket.error) as e: n = 0
>> if n == 0:
>> return count;
>> count += n
>> @@ -43,7 +44,7 @@ host = socket.gethostname()
>>
>> try: serverSocket.bind((host, 0))
>> except socket.error as msg:
>> - print 'bind fails: ', msg
>> + print('bind fails: ' + str(msg))
>>
>> sn = serverSocket.getsockname()
>> serverPort = sn[1]
>> @@ -51,10 +52,10 @@ serverPort = sn[1]
>> cmdStr = ("./tcp_client.py %d &") % (serverPort)
>> os.system(cmdStr)
>>
>> -buf = ''
>> +buf = b''
>> n = 0
>> while n < 500:
>> - buf += '.'
>> + buf += b'.'
>> n += 1
>>
>> serverSocket.listen(MAX_PORTS)
>> @@ -79,5 +80,5 @@ while True:
>> serverSocket.close()
>> sys.exit(0)
>> else:
>> - print 'Select timeout!'
>> + print('Select timeout!')
>> sys.exit(1)
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH] bpf: Add Python 3 support to selftests scripts for bpf
From: jcline @ 2018-07-23 14:08 UTC (permalink / raw)
In-Reply-To: <1aa3dc98-2ab1-7386-d5d9-afd3dbb3fde9@iogearbox.net>
Hi Daniel,
On 07/20/2018 04:45 PM, Daniel Borkmann wrote:
> On 07/18/2018 11:36 PM, Jeremy Cline wrote:
>> Adjust tcp_client.py and tcp_server.py to work with Python 3 by using
>> the print function, marking string literals as bytes, and using the
>> newer exception syntax. This should be functionally equivalent and
>> support Python 2.6 through Python 3.7.
>>
>> Signed-off-by: Jeremy Cline <jcline at redhat.com>
>
> Thanks for the patch, Jeremy! Given we also have test_offload.py in BPF
> kselftests and it is written for python 3 only, it would probably make
> sense to adapt the tcp_{client,server}.py towards python 3 as well, so
> we wouldn't need to keep extra compat for 2 and have a consistent version
> dependency. Lawrence / Jeremy, any objections?
I certainly don't object to Python 3 only and I'm happy to drop the
Python 2 compatibility from this patch if that's okay.
>
>> tools/testing/selftests/bpf/tcp_client.py | 12 ++++++------
>> tools/testing/selftests/bpf/tcp_server.py | 17 +++++++++--------
>> 2 files changed, 15 insertions(+), 14 deletions(-)
>>
>> diff --git a/tools/testing/selftests/bpf/tcp_client.py b/tools/testing/selftests/bpf/tcp_client.py
>> index 481dccdf140c..9fe5f1b5c020 100755
>> --- a/tools/testing/selftests/bpf/tcp_client.py
>> +++ b/tools/testing/selftests/bpf/tcp_client.py
>> @@ -1,4 +1,4 @@
>> -#!/usr/bin/env python2
>> +#!/usr/bin/env python
>> #
>> # SPDX-License-Identifier: GPL-2.0
>> #
>> @@ -9,11 +9,11 @@ import subprocess
>> import select
>>
>> def read(sock, n):
>> - buf = ''
>> + buf = b''
>> while len(buf) < n:
>> rem = n - len(buf)
>> try: s = sock.recv(rem)
>> - except (socket.error), e: return ''
>> + except (socket.error) as e: return b''
>> buf += s
>> return buf
>>
>> @@ -22,7 +22,7 @@ def send(sock, s):
>> count = 0
>> while count < total:
>> try: n = sock.send(s)
>> - except (socket.error), e: n = 0
>> + except (socket.error) as e: n = 0
>> if n == 0:
>> return count;
>> count += n
>> @@ -39,10 +39,10 @@ try:
>> except socket.error as e:
>> sys.exit(1)
>>
>> -buf = ''
>> +buf = b''
>> n = 0
>> while n < 1000:
>> - buf += '+'
>> + buf += b'+'
>> n += 1
>>
>> sock.settimeout(1);
>> diff --git a/tools/testing/selftests/bpf/tcp_server.py b/tools/testing/selftests/bpf/tcp_server.py
>> index bc454d7d0be2..1d4a40a6584b 100755
>> --- a/tools/testing/selftests/bpf/tcp_server.py
>> +++ b/tools/testing/selftests/bpf/tcp_server.py
>> @@ -1,7 +1,8 @@
>> -#!/usr/bin/env python2
>> +#!/usr/bin/env python
>> #
>> # SPDX-License-Identifier: GPL-2.0
>> #
>> +from __future__ import print_function
>>
>> import sys, os, os.path, getopt
>> import socket, time
>> @@ -9,11 +10,11 @@ import subprocess
>> import select
>>
>> def read(sock, n):
>> - buf = ''
>> + buf = b''
>> while len(buf) < n:
>> rem = n - len(buf)
>> try: s = sock.recv(rem)
>> - except (socket.error), e: return ''
>> + except (socket.error) as e: return b''
>> buf += s
>> return buf
>>
>> @@ -22,7 +23,7 @@ def send(sock, s):
>> count = 0
>> while count < total:
>> try: n = sock.send(s)
>> - except (socket.error), e: n = 0
>> + except (socket.error) as e: n = 0
>> if n == 0:
>> return count;
>> count += n
>> @@ -43,7 +44,7 @@ host = socket.gethostname()
>>
>> try: serverSocket.bind((host, 0))
>> except socket.error as msg:
>> - print 'bind fails: ', msg
>> + print('bind fails: ' + str(msg))
>>
>> sn = serverSocket.getsockname()
>> serverPort = sn[1]
>> @@ -51,10 +52,10 @@ serverPort = sn[1]
>> cmdStr = ("./tcp_client.py %d &") % (serverPort)
>> os.system(cmdStr)
>>
>> -buf = ''
>> +buf = b''
>> n = 0
>> while n < 500:
>> - buf += '.'
>> + buf += b'.'
>> n += 1
>>
>> serverSocket.listen(MAX_PORTS)
>> @@ -79,5 +80,5 @@ while True:
>> serverSocket.close()
>> sys.exit(0)
>> else:
>> - print 'Select timeout!'
>> + print('Select timeout!')
>> sys.exit(1)
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] drm/atomic: Check old_plane_state->crtc in drm_atomic_helper_async_check()
From: Sean Paul @ 2018-07-23 14:08 UTC (permalink / raw)
To: Boris Brezillon; +Cc: David Airlie, dri-devel
In-Reply-To: <20180723134354.26298-1-boris.brezillon@bootlin.com>
On Mon, Jul 23, 2018 at 03:43:54PM +0200, Boris Brezillon wrote:
> Async plane update is supposed to work only when updating the FB or FB
> position of an already enabled plane. That does not apply to requests
> where the plane was previously disabled or assigned to a different
> CTRC.
>
> Check old_plane_state->crtc value to make sure async plane update is
> allowed.
>
> Fixes: fef9df8b5945 ("drm/atomic: initial support for asynchronous plane update")
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
> Hello,
>
> As discussed on IRC, I'm not sure this "plane should already be enabled
> and assigned to the same CRTC to allow async updates" limitation
> applies to all drivers, but it's required for VC4 to work properly.
>
> Just let me know if you think I should move this check to
> vc4_plane_atomic_async_check().
I don't _think_ there's any hardware that can switch planes without first
disabling the plane for a frame and then re-enabling it, so this passes the
smell test for me. I'd be very curious to be proven wrong, though :)
Sean
>
> Thanks,
>
> Boris
> ---
> drivers/gpu/drm/drm_atomic_helper.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 866a2cc72ef6..f7ccfebd3ca8 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1555,7 +1555,8 @@ int drm_atomic_helper_async_check(struct drm_device *dev,
> if (n_planes != 1)
> return -EINVAL;
>
> - if (!new_plane_state->crtc)
> + if (!new_plane_state->crtc ||
> + old_plane_state->crtc != new_plane_state->crtc)
> return -EINVAL;
>
> funcs = plane->helper_private;
> --
> 2.14.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply
* [PATCH] iommu/arm-smmu-v3: sync the OVACKFLG to PRIQ consumer register
From: Jean-Philippe Brucker @ 2018-07-23 14:08 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1532350618-16486-1-git-send-email-zhangshaokun@hisilicon.com>
On 23/07/18 13:56, Shaokun Zhang wrote:
> From: Miao Zhong <zhongmiao@hisilicon.com>
>
> When PRI queue occurs overflow, driver should update the OVACKFLG to
> the PRIQ consumer register, otherwise subsequent PRI requests will not
> be processed.
Since the upstream driver doesn't enable PRI in endpoints, I'm not sure
this patch makes sense on its own, but it seems correct anyway. I had a
similar patch in my initial SVA RFC, but for some reason dropped it in
later versions (https://patchwork.kernel.org/patch/9594021/)
It's worth noting that the event queue doesn't have the same problem,
because the SMMU can record new events even if the overflow hasn't been
acknowledged.
Thanks,
Jean
^ permalink raw reply
* Re: [PATCH] iommu/arm-smmu-v3: sync the OVACKFLG to PRIQ consumer register
From: Jean-Philippe Brucker @ 2018-07-23 14:08 UTC (permalink / raw)
To: Shaokun Zhang, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Miao Zhong, Will Deacon
In-Reply-To: <1532350618-16486-1-git-send-email-zhangshaokun-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
On 23/07/18 13:56, Shaokun Zhang wrote:
> From: Miao Zhong <zhongmiao-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
>
> When PRI queue occurs overflow, driver should update the OVACKFLG to
> the PRIQ consumer register, otherwise subsequent PRI requests will not
> be processed.
Since the upstream driver doesn't enable PRI in endpoints, I'm not sure
this patch makes sense on its own, but it seems correct anyway. I had a
similar patch in my initial SVA RFC, but for some reason dropped it in
later versions (https://patchwork.kernel.org/patch/9594021/)
It's worth noting that the event queue doesn't have the same problem,
because the SMMU can record new events even if the overflow hasn't been
acknowledged.
Thanks,
Jean
^ permalink raw reply
* Re: [PATCH] option: Do not try to bind to ADB interfaces
From: Greg Kroah-Hartman @ 2018-07-23 14:08 UTC (permalink / raw)
To: Romain Izard; +Cc: Johan Hovold, linux-usb, linux-kernel, stable
In-Reply-To: <20180723140220.7166-1-romain.izard.pro@gmail.com>
On Mon, Jul 23, 2018 at 04:02:20PM +0200, Romain Izard wrote:
> Some modems now use the Android Debug Bridge to provide a debugging
> interface, and some phones can also export serial ports managed by the
> "option" driver.
>
> The ADB daemon running in userspace tries to use USB interfaces with
> bDeviceClass=0xFF, bDeviceSubClass=0x42, bDeviceProtocol=1
>
> Prevent the option driver from binding to those interfaces, as they
> will not be serial ports.
>
> This can fix issues like:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=781256
>
> Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
> Cc: stable <stable@vger.kernel.org>
> ---
> drivers/usb/serial/option.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
> index 664e61f16b6a..f98943a57ff0 100644
> --- a/drivers/usb/serial/option.c
> +++ b/drivers/usb/serial/option.c
> @@ -1987,6 +1987,12 @@ static int option_probe(struct usb_serial *serial,
> if (iface_desc->bInterfaceClass == USB_CLASS_MASS_STORAGE)
> return -ENODEV;
>
> + /* Do not bind Android Debug Bridge interfaces */
> + if (iface_desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
> + iface_desc->bInterfaceSubClass == 0x42 &&
> + iface_desc->bInterfaceProtocol == 1)
> + return -ENODEV;
Shouldn't you also check the vendor/product id as well? Otherwise this
has the potential to match random devices that are not really adb
devices.
thanks,
greg k-h
^ permalink raw reply
* option: Do not try to bind to ADB interfaces
From: Greg Kroah-Hartman @ 2018-07-23 14:08 UTC (permalink / raw)
To: Romain Izard; +Cc: Johan Hovold, linux-usb, linux-kernel, stable
On Mon, Jul 23, 2018 at 04:02:20PM +0200, Romain Izard wrote:
> Some modems now use the Android Debug Bridge to provide a debugging
> interface, and some phones can also export serial ports managed by the
> "option" driver.
>
> The ADB daemon running in userspace tries to use USB interfaces with
> bDeviceClass=0xFF, bDeviceSubClass=0x42, bDeviceProtocol=1
>
> Prevent the option driver from binding to those interfaces, as they
> will not be serial ports.
>
> This can fix issues like:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=781256
>
> Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
> Cc: stable <stable@vger.kernel.org>
> ---
> drivers/usb/serial/option.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
> index 664e61f16b6a..f98943a57ff0 100644
> --- a/drivers/usb/serial/option.c
> +++ b/drivers/usb/serial/option.c
> @@ -1987,6 +1987,12 @@ static int option_probe(struct usb_serial *serial,
> if (iface_desc->bInterfaceClass == USB_CLASS_MASS_STORAGE)
> return -ENODEV;
>
> + /* Do not bind Android Debug Bridge interfaces */
> + if (iface_desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
> + iface_desc->bInterfaceSubClass == 0x42 &&
> + iface_desc->bInterfaceProtocol == 1)
> + return -ENODEV;
Shouldn't you also check the vendor/product id as well? Otherwise this
has the potential to match random devices that are not really adb
devices.
thanks,
greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [virtio-dev] Re: [PATCH v36 0/5] Virtio-balloon: support free page reporting
From: Michael S. Tsirkin @ 2018-07-23 14:07 UTC (permalink / raw)
To: Wei Wang
Cc: virtio-dev, linux-kernel, virtualization, kvm, linux-mm, mhocko,
akpm, torvalds, pbonzini, liliang.opensource, yang.zhang.wz,
quan.xu0, nilal, riel, peterx, dgilbert
In-Reply-To: <1532075585-39067-1-git-send-email-wei.w.wang@intel.com>
On Fri, Jul 20, 2018 at 04:33:00PM +0800, Wei Wang wrote:
> This patch series is separated from the previous "Virtio-balloon
> Enhancement" series. The new feature, VIRTIO_BALLOON_F_FREE_PAGE_HINT,
> implemented by this series enables the virtio-balloon driver to report
> hints of guest free pages to the host. It can be used to accelerate live
> migration of VMs. Here is an introduction of this usage:
>
> Live migration needs to transfer the VM's memory from the source machine
> to the destination round by round. For the 1st round, all the VM's memory
> is transferred. From the 2nd round, only the pieces of memory that were
> written by the guest (after the 1st round) are transferred. One method
> that is popularly used by the hypervisor to track which part of memory is
> written is to write-protect all the guest memory.
>
> This feature enables the optimization by skipping the transfer of guest
> free pages during VM live migration. It is not concerned that the memory
> pages are used after they are given to the hypervisor as a hint of the
> free pages, because they will be tracked by the hypervisor and transferred
> in the subsequent round if they are used and written.
>
> * Tests
> - Test Environment
> Host: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
> Guest: 8G RAM, 4 vCPU
> Migration setup: migrate_set_speed 100G, migrate_set_downtime 2 second
>
> - Test Results
> - Idle Guest Live Migration Time (results are averaged over 10 runs):
> - Optimization v.s. Legacy = 409ms vs 1757ms --> ~77% reduction
> (setting page poisoning zero and enabling ksm don't affect the
> comparison result)
> - Guest with Linux Compilation Workload (make bzImage -j4):
> - Live Migration Time (average)
> Optimization v.s. Legacy = 1407ms v.s. 2528ms --> ~44% reduction
> - Linux Compilation Time
> Optimization v.s. Legacy = 5min4s v.s. 5min12s
> --> no obvious difference
I'd like to see dgilbert's take on whether this kind of gain
justifies adding a PV interfaces, and what kind of guest workload
is appropriate.
Cc'd.
> ChangeLog:
> v35->v36:
> - remove the mm patch, as Linus has a suggestion to get free page
> addresses via allocation, instead of reading from the free page
> list.
> - virtio-balloon:
> - replace oom notifier with shrinker;
> - the guest to host communication interface remains the same as
> v32.
> - allocate free page blocks and send to host one by one, and free
> them after sending all the pages.
>
> For ChangeLogs from v22 to v35, please reference
> https://lwn.net/Articles/759413/
>
> For ChangeLogs before v21, please reference
> https://lwn.net/Articles/743660/
>
> Wei Wang (5):
> virtio-balloon: remove BUG() in init_vqs
> virtio_balloon: replace oom notifier with shrinker
> virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT
> mm/page_poison: expose page_poisoning_enabled to kernel modules
> virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON
>
> drivers/virtio/virtio_balloon.c | 456 ++++++++++++++++++++++++++++++------
> include/uapi/linux/virtio_balloon.h | 7 +
> mm/page_poison.c | 6 +
> 3 files changed, 394 insertions(+), 75 deletions(-)
>
> --
> 2.7.4
---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
^ permalink raw reply
* Re: Is thin provisioning still experimental?
From: Mike Snitzer @ 2018-07-23 14:07 UTC (permalink / raw)
To: Drew Hastings; +Cc: dm-devel
In-Reply-To: <20180723140053.GA28984@redhat.com>
On Mon, Jul 23 2018 at 10:00am -0400,
Mike Snitzer <snitzer@redhat.com> wrote:
> On Mon, Jul 23 2018 at 1:06am -0400,
> Drew Hastings <dhastings@crucialwebhost.com> wrote:
>
> > I love all of the work you guys do @dm-devel . Thanks for taking the time
> > to read this.
> > I would like to use thin provisioning targets in production, but it's hard
> > to ignore the warning in the documentation. It seems like, with an
> > understanding of how thin provisioning works, it should be safe to use.
>
> It is stale. I just committed this update that'll go upstream for the
> 4.19 merge window, see:
> https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.19&id=f88a3f746ff0047c92e8312646247b08264daf35
>
> > If the metadata and data device for the thin pool have enough space and
> > are both error free, the kernel has plenty of free RAM, block sizes are
> > set large enough to never run into performance issues (64 MiB), all of the
> > underlying hardware is redundant on high performance NVME (no worries of
> > fragmentation of data volume)... is it still unsafe for production? If so,
> > can you shed some light on why that is?
>
> It is safe. You do just want to make sure to not run out of space. We
> now handle that event favorably but it is best to tempt fate.
I meant: "... but it is best to _not_ tempt fate."
^ permalink raw reply
* Re: [PATCH v36 0/5] Virtio-balloon: support free page reporting
From: Michael S. Tsirkin @ 2018-07-23 14:07 UTC (permalink / raw)
To: Wei Wang
Cc: virtio-dev, linux-kernel, virtualization, kvm, linux-mm, mhocko,
akpm, torvalds, pbonzini, liliang.opensource, yang.zhang.wz,
quan.xu0, nilal, riel, peterx, dgilbert
In-Reply-To: <1532075585-39067-1-git-send-email-wei.w.wang@intel.com>
On Fri, Jul 20, 2018 at 04:33:00PM +0800, Wei Wang wrote:
> This patch series is separated from the previous "Virtio-balloon
> Enhancement" series. The new feature, VIRTIO_BALLOON_F_FREE_PAGE_HINT,
> implemented by this series enables the virtio-balloon driver to report
> hints of guest free pages to the host. It can be used to accelerate live
> migration of VMs. Here is an introduction of this usage:
>
> Live migration needs to transfer the VM's memory from the source machine
> to the destination round by round. For the 1st round, all the VM's memory
> is transferred. From the 2nd round, only the pieces of memory that were
> written by the guest (after the 1st round) are transferred. One method
> that is popularly used by the hypervisor to track which part of memory is
> written is to write-protect all the guest memory.
>
> This feature enables the optimization by skipping the transfer of guest
> free pages during VM live migration. It is not concerned that the memory
> pages are used after they are given to the hypervisor as a hint of the
> free pages, because they will be tracked by the hypervisor and transferred
> in the subsequent round if they are used and written.
>
> * Tests
> - Test Environment
> Host: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
> Guest: 8G RAM, 4 vCPU
> Migration setup: migrate_set_speed 100G, migrate_set_downtime 2 second
>
> - Test Results
> - Idle Guest Live Migration Time (results are averaged over 10 runs):
> - Optimization v.s. Legacy = 409ms vs 1757ms --> ~77% reduction
> (setting page poisoning zero and enabling ksm don't affect the
> comparison result)
> - Guest with Linux Compilation Workload (make bzImage -j4):
> - Live Migration Time (average)
> Optimization v.s. Legacy = 1407ms v.s. 2528ms --> ~44% reduction
> - Linux Compilation Time
> Optimization v.s. Legacy = 5min4s v.s. 5min12s
> --> no obvious difference
I'd like to see dgilbert's take on whether this kind of gain
justifies adding a PV interfaces, and what kind of guest workload
is appropriate.
Cc'd.
> ChangeLog:
> v35->v36:
> - remove the mm patch, as Linus has a suggestion to get free page
> addresses via allocation, instead of reading from the free page
> list.
> - virtio-balloon:
> - replace oom notifier with shrinker;
> - the guest to host communication interface remains the same as
> v32.
> - allocate free page blocks and send to host one by one, and free
> them after sending all the pages.
>
> For ChangeLogs from v22 to v35, please reference
> https://lwn.net/Articles/759413/
>
> For ChangeLogs before v21, please reference
> https://lwn.net/Articles/743660/
>
> Wei Wang (5):
> virtio-balloon: remove BUG() in init_vqs
> virtio_balloon: replace oom notifier with shrinker
> virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT
> mm/page_poison: expose page_poisoning_enabled to kernel modules
> virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON
>
> drivers/virtio/virtio_balloon.c | 456 ++++++++++++++++++++++++++++++------
> include/uapi/linux/virtio_balloon.h | 7 +
> mm/page_poison.c | 6 +
> 3 files changed, 394 insertions(+), 75 deletions(-)
>
> --
> 2.7.4
^ permalink raw reply
* Re: [PATCH v36 0/5] Virtio-balloon: support free page reporting
From: Michael S. Tsirkin @ 2018-07-23 14:07 UTC (permalink / raw)
To: Wei Wang
Cc: yang.zhang.wz, virtio-dev, riel, quan.xu0, kvm, nilal,
liliang.opensource, linux-kernel, mhocko, linux-mm, pbonzini,
akpm, virtualization, torvalds, dgilbert
In-Reply-To: <1532075585-39067-1-git-send-email-wei.w.wang@intel.com>
On Fri, Jul 20, 2018 at 04:33:00PM +0800, Wei Wang wrote:
> This patch series is separated from the previous "Virtio-balloon
> Enhancement" series. The new feature, VIRTIO_BALLOON_F_FREE_PAGE_HINT,
> implemented by this series enables the virtio-balloon driver to report
> hints of guest free pages to the host. It can be used to accelerate live
> migration of VMs. Here is an introduction of this usage:
>
> Live migration needs to transfer the VM's memory from the source machine
> to the destination round by round. For the 1st round, all the VM's memory
> is transferred. From the 2nd round, only the pieces of memory that were
> written by the guest (after the 1st round) are transferred. One method
> that is popularly used by the hypervisor to track which part of memory is
> written is to write-protect all the guest memory.
>
> This feature enables the optimization by skipping the transfer of guest
> free pages during VM live migration. It is not concerned that the memory
> pages are used after they are given to the hypervisor as a hint of the
> free pages, because they will be tracked by the hypervisor and transferred
> in the subsequent round if they are used and written.
>
> * Tests
> - Test Environment
> Host: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
> Guest: 8G RAM, 4 vCPU
> Migration setup: migrate_set_speed 100G, migrate_set_downtime 2 second
>
> - Test Results
> - Idle Guest Live Migration Time (results are averaged over 10 runs):
> - Optimization v.s. Legacy = 409ms vs 1757ms --> ~77% reduction
> (setting page poisoning zero and enabling ksm don't affect the
> comparison result)
> - Guest with Linux Compilation Workload (make bzImage -j4):
> - Live Migration Time (average)
> Optimization v.s. Legacy = 1407ms v.s. 2528ms --> ~44% reduction
> - Linux Compilation Time
> Optimization v.s. Legacy = 5min4s v.s. 5min12s
> --> no obvious difference
I'd like to see dgilbert's take on whether this kind of gain
justifies adding a PV interfaces, and what kind of guest workload
is appropriate.
Cc'd.
> ChangeLog:
> v35->v36:
> - remove the mm patch, as Linus has a suggestion to get free page
> addresses via allocation, instead of reading from the free page
> list.
> - virtio-balloon:
> - replace oom notifier with shrinker;
> - the guest to host communication interface remains the same as
> v32.
> - allocate free page blocks and send to host one by one, and free
> them after sending all the pages.
>
> For ChangeLogs from v22 to v35, please reference
> https://lwn.net/Articles/759413/
>
> For ChangeLogs before v21, please reference
> https://lwn.net/Articles/743660/
>
> Wei Wang (5):
> virtio-balloon: remove BUG() in init_vqs
> virtio_balloon: replace oom notifier with shrinker
> virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT
> mm/page_poison: expose page_poisoning_enabled to kernel modules
> virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON
>
> drivers/virtio/virtio_balloon.c | 456 ++++++++++++++++++++++++++++++------
> include/uapi/linux/virtio_balloon.h | 7 +
> mm/page_poison.c | 6 +
> 3 files changed, 394 insertions(+), 75 deletions(-)
>
> --
> 2.7.4
^ permalink raw reply
* Re: [PATCH v4 02/20] virtio: pci-legacy: Validate queue pfn
From: Michael S. Tsirkin @ 2018-07-23 14:20 UTC (permalink / raw)
To: Marc Zyngier
Cc: cdall, kvm, catalin.marinas, Jason Wang, will.deacon, dave.martin,
pbonzini, kvmarm, linux-arm-kernel
In-Reply-To: <db295a96-cf1e-9e8b-9b29-5882084781e1@arm.com>
On Mon, Jul 23, 2018 at 01:54:10PM +0100, Marc Zyngier wrote:
> On 23/07/18 10:44, Suzuki K Poulose wrote:
> > On 07/22/2018 04:53 PM, Michael S. Tsirkin wrote:
> >> On Wed, Jul 18, 2018 at 10:18:45AM +0100, Suzuki K Poulose wrote:
> >>> Legacy PCI over virtio uses a 32bit PFN for the queue. If the
> >>> queue pfn is too large to fit in 32bits, which we could hit on
> >>> arm64 systems with 52bit physical addresses (even with 64K page
> >>> size), we simply miss out a proper link to the other side of
> >>> the queue.
> >>>
> >>> Add a check to validate the PFN, rather than silently breaking
> >>> the devices.
> >>>
> >>> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> >>> Cc: Jason Wang <jasowang@redhat.com>
> >>> Cc: Marc Zyngier <marc.zyngier@arm.com>
> >>> Cc: Christoffer Dall <cdall@kernel.org>
> >>> Cc: Peter Maydel <peter.maydell@linaro.org>
> >>> Cc: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
> >>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> >>
> >> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> >
> >
> > Michael,
> >
> > Thanks.
> >
> >>
> >> I assume this will be merged through some other tree.
> >>
> >
> >
> > As such these two virtio patches do not have any code dependencies with
> > the rest of the series. So, if you could pick this up it should be fine.
> > Otherwise, may be Marc can push it with the rest of the series.
> >
> > Marc,
> >
> > Are you OK with that ?
>
> Given that these two patches completely independent, I think their
> natural path should be the virtio tree. But if Michael doesn't want to
> pick them, I'll do it as part of this series.
>
> Thanks,
>
> M.
It's ok, I can pick them up.
> --
> Jazz is not dead. It just smells funny...
^ permalink raw reply
* Re: INFO: task hung in fuse_reverse_inval_entry
From: Miklos Szeredi @ 2018-07-23 13:05 UTC (permalink / raw)
To: Dmitry Vyukov; +Cc: linux-fsdevel, LKML, syzkaller-bugs, syzbot
In-Reply-To: <CACT4Y+bSnJjtgeLdusj6czbH8080XfRs2b8L0V4R0TAixqxX6Q@mail.gmail.com>
On Mon, Jul 23, 2018 at 2:46 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> On Mon, Jul 23, 2018 at 2:33 PM, Miklos Szeredi <miklos@szeredi.hu> wrote:
>>>>> On Mon, Jul 23, 2018 at 9:59 AM, syzbot
>>>>> <syzbot+bb6d800770577a083f8c@syzkaller.appspotmail.com> wrote:
>>>>>> Hello,
>>>>>>
>>>>>> syzbot found the following crash on:
>>>>>>
>>>>>> HEAD commit: d72e90f33aa4 Linux 4.18-rc6
>>>>>> git tree: upstream
>>>>>> console output: https://syzkaller.appspot.com/x/log.txt?x=1324f794400000
>>>>>> kernel config: https://syzkaller.appspot.com/x/.config?x=68af3495408deac5
>>>>>> dashboard link: https://syzkaller.appspot.com/bug?extid=bb6d800770577a083f8c
>>>>>> compiler: gcc (GCC) 8.0.1 20180413 (experimental)
>>>>>> syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=11564d1c400000
>>>>>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16fc570c400000
>>>>>
>>>>>
>>>>> Hi fuse maintainers,
>>>>>
>>>>> We are seeing a bunch of such deadlocks in fuse on syzbot. As far as I
>>>>> understand this is mostly working-as-intended (parts about deadlocks
>>>>> in Documentation/filesystems/fuse.txt). The intended way to resolve
>>>>> this is aborting connections via fusectl, right?
>>>>
>>>> Yes. Alternative is with "umount -f".
>>>>
>>>>> The doc says "Under
>>>>> the fuse control filesystem each connection has a directory named by a
>>>>> unique number". The question is: if I start a process and this process
>>>>> can mount fuse, how do I kill it? I mean: totally and certainly get
>>>>> rid of it right away? How do I find these unique numbers for the
>>>>> mounts it created?
>>>>
>>>> It is the device number found in st_dev for the mount. Other than
>>>> doing stat(2) it is possible to find out the device number by reading
>>>> /proc/$PID/mountinfo (third field).
>>>
>>> Thanks. I will try to figure out fusectl connection numbers and see if
>>> it's possible to integrate aborting into syzkaller.
>>>
>>>>> Taking into account that there is usually no
>>>>> operator attached to each server, I wonder if kernel could somehow
>>>>> auto-abort fuse on kill?
>>>>
>>>> Depends on what the fuse server is sleeping on. If it's trying to
>>>> acquire an inode lock (e.g. unlink(2)), which is classical way to
>>>> deadlock a fuse filesystem, then it will go into an uninterruptible
>>>> sleep. There's no way in which that process can be killed except to
>>>> force a release of the offending lock, which can only be done by
>>>> aborting the request that is being performed while holding that lock.
>>>
>>> I understand that it is not killed today, but I am asking if we can
>>> make it killable. It's all code that we can change, and if a human
>>> operator can do it, it can be done pure programmatically on kill too,
>>> right?
>>
>> Hmm, you mean if a process is in an uninterruptible sleep trying to
>> acquire a lock on a fuse filesystem and is killed, then the fuse
>> filesystem should be aborted?
>>
>> Even if we'd manage to implement that, it's a large backward
>> incompatibility risk.
>>
>> I don't argue that it can be done, but I would definitely argue *if*
>> it should be done.
>
>
> I understand that we should abort only if we are sure that it's
> actually deadlocked and there is no other way.
> So if fuse-user process is blocked on fuse lock, then we probably
> should do nothing. However, if the fuse-server is killed, then perhaps
> we could abort the connection at that point. Namely, if a process that
> has a fuse fd open is killed and it is the only process that shared
> this fd, then we could abort the connection on arrival of the kill
> signal (rather than wait untill all it's threads finish and then start
> closing all fd's, this is where we get the deadlock -- some of its
> threads won't finish). I don't know if such synchronous kill hook is
> available, though. If several processes shared the same fuse fd, then
> we could close the fd in each process on SIGKILL arrival, then when
> all of these processes are killed, fuse fd will be closed and we can
> abort the connection, which will un-deadlock all of these processes.
> Does this look any reasonable?
Biggest conceptual problem: your definition of fuse-server is weak.
Take the following example: process A is holding the fuse device fd
and is forwarding requests and replies to/from process B via a pipe.
So basically A is just a proxy that does nothing interesting, the
"real" server is B. But according to your definition B is not a
server, only A is.
And this is just a simple example, parts of the server might be on
different machines, etc... It's impossible to automatically detect if
a process is acting as a fuse server or not.
We could let the fuse server itself notify the kernel that it's a fuse
server. That might help in the cases where the deadlock is
accidental, but obviously not in the case when done by a malicious
agent. I'm not sure it's worth the effort. Also I have no idea how
the respective maintainers would take the idea of "kill hooks"... It
would probably be a lot of work for little gain.
Thanks,
Miklos
^ permalink raw reply
* Re: [PATCH 6/8] clk: tegra30: add 2d and 3d idle clocks
From: Dmitry Osipenko @ 2018-07-23 13:05 UTC (permalink / raw)
To: Ben Dooks
Cc: linux-clk, linux-tegra, linux-kernel, pdeschrijver, pgaikwad,
jonathanh, thierry.reding, linux-kernel
In-Reply-To: <20180720134532.13148-7-ben.dooks@codethink.co.uk>
On Friday, 20 July 2018 16:45:30 MSK Ben Dooks wrote:
> The 2D and 3D clocks have an IDLE field in bits 15:8 so add these
> clocks by making a 2D and 3D mux, and split the divider into the
> standard 2D/3D ones and 2D/3D idle clocks.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> drivers/clk/tegra/clk-id.h | 4 ++++
> drivers/clk/tegra/clk-tegra-periph.c | 23 +++++++++++++++++++++--
> drivers/clk/tegra/clk-tegra30.c | 8 ++++++++
> include/dt-bindings/clock/tegra30-car.h | 7 ++++++-
> 4 files changed, 39 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/tegra/clk-id.h b/drivers/clk/tegra/clk-id.h
> index b616e33c5255..0d202a70ce66 100644
> --- a/drivers/clk/tegra/clk-id.h
> +++ b/drivers/clk/tegra/clk-id.h
> @@ -91,8 +91,12 @@ enum clk_id {
> tegra_clk_fuse_burn,
> tegra_clk_gpu,
> tegra_clk_gr2d,
> + tegra_clk_gr2d_mux,
> + tegra_clk_gr2d_idle,
> tegra_clk_gr2d_8,
> tegra_clk_gr3d,
> + tegra_clk_gr3d_mux,
> + tegra_clk_gr3d_idle,
> tegra_clk_gr3d_8,
> tegra_clk_hclk,
> tegra_clk_hda,
> diff --git a/drivers/clk/tegra/clk-tegra-periph.c
> b/drivers/clk/tegra/clk-tegra-periph.c index 47e5b1ac1a69..83967dac93f2
> 100644
> --- a/drivers/clk/tegra/clk-tegra-periph.c
> +++ b/drivers/clk/tegra/clk-tegra-periph.c
> @@ -263,6 +263,21 @@
> .flags = _flags, \
> }
>
> +#define GATE_DIV(_name, _parent_name, _offset, \
> + _div_shift, _div_width, _div_frac_width, _div_flags, \
> + _clk_num, _gate_flags, _clk_id, _flags) \
> + { \
> + .name = _name, \
> + .clk_id = _clk_id, \
> + .offset = _offset, \
> + .p.parent_name = _parent_name, \
> + .periph = TEGRA_CLK_PERIPH(0, 0, 0, \
> + _div_shift, _div_width, \
> + _div_frac_width, _div_flags, \
> + _clk_num, _gate_flags, NULL, NULL), \
> + .flags = _flags \
> + }
> +
> #define PLLP_BASE 0xa0
> #define PLLP_MISC 0xac
> #define PLLP_MISC1 0x680
> @@ -646,8 +661,12 @@ static struct tegra_periph_init_data periph_clks[] = {
> MUX("epp", mux_pllm_pllc_pllp_plla, CLK_SOURCE_EPP, 19, 0,
tegra_clk_epp),
> MUX("host1x", mux_pllm_pllc_pllp_plla, CLK_SOURCE_HOST1X, 28, 0,
> tegra_clk_host1x), MUX("mpe", mux_pllm_pllc_pllp_plla, CLK_SOURCE_MPE, 60,
> 0, tegra_clk_mpe), - MUX("2d", mux_pllm_pllc_pllp_plla, CLK_SOURCE_2D,
21,
> 0, tegra_clk_gr2d), - MUX("3d", mux_pllm_pllc_pllp_plla, CLK_SOURCE_3D,
24,
> 0, tegra_clk_gr3d), + MUX("2d_mux", mux_pllm_pllc_pllp_plla,
CLK_SOURCE_2D,
> 0, TEGRA_PERIPH_NO_DIV | TEGRA_PERIPH_NO_RESET | TEGRA_PERIPH_NO_GATE,
> tegra_clk_gr2d_mux), + GATE_DIV("2d", "2d_mux", CLK_SOURCE_2D, 0, 8, 1,
> TEGRA_DIVIDER_ROUND_UP,21, 0, tegra_clk_gr2d, 0), + GATE_DIV("2d_idle",
> "2d_mux", CLK_SOURCE_2D, 8, 8, 1, TEGRA_DIVIDER_ROUND_UP, 0,
> TEGRA_PERIPH_NO_GATE | TEGRA_PERIPH_NO_RESET, tegra_clk_gr2d_idle, 0),
> + MUX("3d_mux", mux_pllm_pllc_pllp_plla, CLK_SOURCE_3D, 0,
Now that the actual parent clock is specified by the "mux" clock, you have to
adjust the tegra_clk_init_table accordingly.
^ permalink raw reply
* Re: [PATCH v3 5/5] drm/vkms: Implement CRC debugfs API
From: Sean Paul @ 2018-07-23 14:05 UTC (permalink / raw)
To: Haneen Mohammed; +Cc: rodrigosiqueiramelo, dri-devel
In-Reply-To: <f7400b0db272566f135adbb1f777d487765ff2a0.1531955948.git.hamohammed.sa@gmail.com>
On Thu, Jul 19, 2018 at 03:22:16AM +0300, Haneen Mohammed wrote:
> Implement the set_crc_source() callback.
> Compute CRC using crc32 on the visible part of the framebuffer.
> Use ordered workqueue to compute and add CRC at the end of a vblank.
>
> Use appropriate synchronization methods since the CRC computation must
> be atomic wrt the generated vblank event for a given atomic update, by
> using spinlock across atomic_begin and atomic_flush to wrap the event
> handling code completely and match the flip event with the CRC.
>
> Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>
> ---
> Changes in v3:
> - flush work item instead of workqueue
> - include missing vkms_crc.c file
>
> drivers/gpu/drm/vkms/Makefile | 2 +-
> drivers/gpu/drm/vkms/vkms_crc.c | 66 +++++++++++++++++++++++++++++++
> drivers/gpu/drm/vkms/vkms_crtc.c | 58 ++++++++++++++++++++++-----
> drivers/gpu/drm/vkms/vkms_drv.c | 1 +
> drivers/gpu/drm/vkms/vkms_drv.h | 21 ++++++++++
> drivers/gpu/drm/vkms/vkms_plane.c | 10 +++++
> 6 files changed, 148 insertions(+), 10 deletions(-)
> create mode 100644 drivers/gpu/drm/vkms/vkms_crc.c
>
> diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile
> index 986297da51bf..37966914f70b 100644
> --- a/drivers/gpu/drm/vkms/Makefile
> +++ b/drivers/gpu/drm/vkms/Makefile
> @@ -1,3 +1,3 @@
> -vkms-y := vkms_drv.o vkms_plane.o vkms_output.o vkms_crtc.o vkms_gem.o
> +vkms-y := vkms_drv.o vkms_plane.o vkms_output.o vkms_crtc.o vkms_gem.o vkms_crc.o
>
> obj-$(CONFIG_DRM_VKMS) += vkms.o
> diff --git a/drivers/gpu/drm/vkms/vkms_crc.c b/drivers/gpu/drm/vkms/vkms_crc.c
> new file mode 100644
> index 000000000000..9e8bb5c7fc80
> --- /dev/null
> +++ b/drivers/gpu/drm/vkms/vkms_crc.c
> @@ -0,0 +1,66 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include "vkms_drv.h"
> +#include <linux/crc32.h>
> +#include <drm/drm_gem_framebuffer_helper.h>
> +
> +static uint32_t _vkms_get_crc(struct vkms_crc_data *crc_data)
> +{
> + struct drm_framebuffer *fb = &crc_data->fb;
> + struct drm_gem_object *gem_obj = drm_gem_fb_get_obj(fb, 0);
> + struct vkms_gem_object *vkms_obj = drm_gem_to_vkms_gem(gem_obj);
> + u32 crc = 0;
> + int i = 0;
> + unsigned int x = crc_data->src.x1 >> 16;
> + unsigned int y = crc_data->src.y1 >> 16;
> + unsigned int height = drm_rect_height(&crc_data->src) >> 16;
> + unsigned int width = drm_rect_width(&crc_data->src) >> 16;
> + unsigned int cpp = fb->format->cpp[0];
> + unsigned int src_offset;
> + unsigned int size_byte = width * cpp;
> + void *vaddr = vkms_obj->vaddr;
You should hold the lock when copying the data from crc_data.
> +
> + if (WARN_ON(!vaddr))
> + return crc;
> +
> + for (i = y; i < y + height; i++) {
> + src_offset = fb->offsets[0] + (i * fb->pitches[0]) + (x * cpp);
> + crc = crc32_le(crc, vaddr + src_offset, size_byte);
> + }
> +
> + return crc;
> +}
> +
> +void vkms_crc_work_handle(struct work_struct *work)
> +{
> + struct vkms_crtc_state *crtc_state = container_of(work,
> + struct vkms_crtc_state,
> + crc_work);
> + struct drm_crtc *crtc = crtc_state->base.crtc;
> + struct vkms_output *out = drm_crtc_to_vkms_output(crtc);
> +
> + if (crtc_state && out->crc_enabled) {
> + u32 crc32 = _vkms_get_crc(&crtc_state->data);
> + unsigned int n_frame = crtc_state->n_frame;
> +
> + drm_crtc_add_crc_entry(crtc, true, n_frame, &crc32);
> + }
> +}
> +
> +int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name,
> + size_t *values_cnt)
> +{
> + struct vkms_output *out = drm_crtc_to_vkms_output(crtc);
> +
You should hold the lock when changing this value.
> + if (!src_name) {
> + out->crc_enabled = false;
> + } else if (strcmp(src_name, "auto") == 0) {
> + out->crc_enabled = true;
> + } else {
> + out->crc_enabled = false;
> + return -EINVAL;
> + }
> +
> + *values_cnt = 1;
> +
> + return 0;
> +}
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 26babb85ca77..a7b39627b581 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -10,17 +10,32 @@
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_crtc_helper.h>
>
> -static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
> +static void _vblank_handle(struct vkms_output *output)
> {
> - struct vkms_output *output = container_of(timer, struct vkms_output,
> - vblank_hrtimer);
> struct drm_crtc *crtc = &output->crtc;
> - int ret_overrun;
> + struct vkms_crtc_state *state = to_vkms_crtc_state(crtc->state);
> bool ret;
>
> + spin_lock(&output->lock);
> ret = drm_crtc_handle_vblank(crtc);
> if (!ret)
> - DRM_ERROR("vkms failure on handling vblank");
> + DRM_ERROR("vkms failure on handling vblank\n");
> +
> + if (state && output->crc_enabled) {
> + state->n_frame = drm_crtc_accurate_vblank_count(crtc);
> + queue_work(output->crc_workq, &state->crc_work);
> + }
> +
> + spin_unlock(&output->lock);
> +}
> +
> +static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
> +{
> + struct vkms_output *output = container_of(timer, struct vkms_output,
> + vblank_hrtimer);
> + int ret_overrun;
> +
> + _vblank_handle(output);
>
> ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer,
> output->period_ns);
> @@ -97,6 +112,8 @@ vkms_atomic_crtc_duplicate_state(struct drm_crtc *crtc)
>
> __drm_atomic_helper_crtc_duplicate_state(crtc, &vkms_state->base);
>
> + INIT_WORK(&vkms_state->crc_work, vkms_crc_work_handle);
> +
> return &vkms_state->base;
> }
>
> @@ -108,7 +125,13 @@ static void vkms_atomic_crtc_destroy_state(struct drm_crtc *crtc,
> vkms_state = to_vkms_crtc_state(state);
>
> __drm_atomic_helper_crtc_destroy_state(state);
> - kfree(vkms_state);
> +
> + if (vkms_state) {
> + flush_work(&vkms_state->crc_work);
> + drm_framebuffer_put(&vkms_state->data.fb);
It'd be nice to leave a breadcrumb explaining where this reference is acquired.
ie: /* dropping the reference we acquired in vkms_primary_plane_update() */
> + memset(&vkms_state->data, 0, sizeof(struct vkms_crc_data));
> + kfree(vkms_state);
> + }
> }
>
> static const struct drm_crtc_funcs vkms_crtc_funcs = {
> @@ -120,6 +143,7 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = {
> .atomic_destroy_state = vkms_atomic_crtc_destroy_state,
> .enable_vblank = vkms_enable_vblank,
> .disable_vblank = vkms_disable_vblank,
> + .set_crc_source = vkms_set_crc_source,
> };
>
> static void vkms_crtc_atomic_enable(struct drm_crtc *crtc,
> @@ -134,26 +158,37 @@ static void vkms_crtc_atomic_disable(struct drm_crtc *crtc,
> drm_crtc_vblank_off(crtc);
> }
>
> +static void vkms_crtc_atomic_begin(struct drm_crtc *crtc,
> + struct drm_crtc_state *old_crtc_state)
> +{
> + struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc);
> +
> + spin_lock_irq(&vkms_output->lock);
Can you please add a comment explaining that we're holding this across the
commit to block the vblank timer, and why.
> +}
> +
> static void vkms_crtc_atomic_flush(struct drm_crtc *crtc,
> struct drm_crtc_state *old_crtc_state)
> {
> - unsigned long flags;
> + struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc);
>
> if (crtc->state->event) {
> - spin_lock_irqsave(&crtc->dev->event_lock, flags);
> + spin_lock(&crtc->dev->event_lock);
Either don't change this (since it's always safe to call _irqsave), or add a
comment explaining why you don't need to.
>
> if (drm_crtc_vblank_get(crtc) != 0)
> drm_crtc_send_vblank_event(crtc, crtc->state->event);
> else
> drm_crtc_arm_vblank_event(crtc, crtc->state->event);
>
> - spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
> + spin_unlock(&crtc->dev->event_lock);
>
> crtc->state->event = NULL;
> }
> +
> + spin_unlock_irq(&vkms_output->lock);
> }
>
> static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = {
> + .atomic_begin = vkms_crtc_atomic_begin,
> .atomic_flush = vkms_crtc_atomic_flush,
> .atomic_enable = vkms_crtc_atomic_enable,
> .atomic_disable = vkms_crtc_atomic_disable,
> @@ -162,6 +197,7 @@ static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = {
> int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> struct drm_plane *primary, struct drm_plane *cursor)
> {
> + struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc);
> int ret;
>
> ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor,
> @@ -173,5 +209,9 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
>
> drm_crtc_helper_add(crtc, &vkms_crtc_helper_funcs);
>
> + spin_lock_init(&vkms_out->lock);
> +
> + vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
> +
> return ret;
> }
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
> index 37aa2ef33b21..5d78bd97e69c 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.c
> +++ b/drivers/gpu/drm/vkms/vkms_drv.c
> @@ -46,6 +46,7 @@ static void vkms_release(struct drm_device *dev)
> platform_device_unregister(vkms->platform);
> drm_mode_config_cleanup(&vkms->drm);
> drm_dev_fini(&vkms->drm);
> + destroy_workqueue(vkms->output.crc_workq);
> }
>
> static struct drm_driver vkms_driver = {
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> index 75e52d61e65d..a80281a12010 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.h
> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> @@ -20,12 +20,23 @@ static const u32 vkms_formats[] = {
> DRM_FORMAT_XRGB8888,
> };
>
> +struct vkms_crc_data {
> + struct drm_rect src;
> + struct drm_framebuffer fb;
> +};
> +
> /**
> * vkms_crtc_state - Driver specific CRTC state
> * @base: base CRTC state
> + * @crc_work: work struct to compute and add CRC entries
> + * @data: data required for CRC computation
> + * @n_frame: frame number for computed CRC
> */
> struct vkms_crtc_state {
> struct drm_crtc_state base;
> + struct work_struct crc_work;
> + struct vkms_crc_data data;
> + unsigned int n_frame;
> };
>
> struct vkms_output {
> @@ -35,6 +46,11 @@ struct vkms_output {
> struct hrtimer vblank_hrtimer;
> ktime_t period_ns;
> struct drm_pending_vblank_event *event;
> + bool crc_enabled;
> + /* ordered wq for crc_work */
> + struct workqueue_struct *crc_workq;
> + /* protects concurrent access to crc_data */
> + spinlock_t lock;
> };
>
> struct vkms_device {
> @@ -95,4 +111,9 @@ int vkms_gem_vmap(struct drm_gem_object *obj);
>
> void vkms_gem_vunmap(struct drm_gem_object *obj);
>
> +/* CRC Support */
> +int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name,
> + size_t *values_cnt);
> +void vkms_crc_work_handle(struct work_struct *work);
> +
> #endif /* _VKMS_DRV_H_ */
> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
> index 5b7c5d59f103..b316b2af88ee 100644
> --- a/drivers/gpu/drm/vkms/vkms_plane.c
> +++ b/drivers/gpu/drm/vkms/vkms_plane.c
> @@ -24,6 +24,16 @@ static const struct drm_plane_funcs vkms_plane_funcs = {
> static void vkms_primary_plane_update(struct drm_plane *plane,
> struct drm_plane_state *old_state)
> {
> + struct vkms_crtc_state *state;
> +
> + if (!plane->state->crtc || !plane->state->fb)
> + return;
> +
> + state = to_vkms_crtc_state(plane->state->crtc->state);
> + memcpy(&state->data.src, &plane->state->src, sizeof(struct drm_rect));
> + memcpy(&state->data.fb, plane->state->fb,
> + sizeof(struct drm_framebuffer));
> + drm_framebuffer_get(&state->data.fb);
Similarly to above, a comment explaining this is released in state_destroy would
be helpful.
> }
>
> static int vkms_plane_atomic_check(struct drm_plane *plane,
> --
> 2.17.1
>
--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply
* [PATCH v2 12/15] xfs: remove all boilerplate defer init/finish code
From: Brian Foster @ 2018-07-23 13:04 UTC (permalink / raw)
To: linux-xfs
In-Reply-To: <20180723130414.47980-1-bfoster@redhat.com>
At this point, the transaction subsystem completely manages deferred
items internally such that the common and boilerplate
xfs_trans_alloc() -> xfs_defer_init() -> xfs_defer_finish() ->
xfs_trans_commit() sequence can be replaced with a simple
transaction allocation and commit.
Remove all such boilerplate deferred ops code. In doing so, we
change each case over to use the dfops in the transaction and
specifically eliminate:
- The on-stack dfops and associated xfs_defer_init() call, as the
internal dfops is initialized on transaction allocation.
- xfs_bmap_finish() calls that precede a final xfs_trans_commit() of
a transaction.
- xfs_defer_cancel() calls in error handlers that precede a
transaction cancel.
The only deferred ops calls that remain are those that are
non-deterministic with respect to the final commit of the associated
transaction or are open-coded due to special handling.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/libxfs/xfs_bmap.c | 16 +-------
fs/xfs/libxfs/xfs_refcount.c | 10 +----
fs/xfs/xfs_attr_inactive.c | 2 -
fs/xfs/xfs_bmap_util.c | 43 +++-----------------
fs/xfs/xfs_dquot.c | 4 --
fs/xfs/xfs_inode.c | 79 ++++++------------------------------
fs/xfs/xfs_iomap.c | 26 +-----------
fs/xfs/xfs_iops.c | 2 -
fs/xfs/xfs_log_recover.c | 8 ----
fs/xfs/xfs_qm_syscalls.c | 2 -
fs/xfs/xfs_reflink.c | 37 ++++++-----------
fs/xfs/xfs_rtalloc.c | 9 +---
fs/xfs/xfs_symlink.c | 38 ++++-------------
13 files changed, 44 insertions(+), 232 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 7b93b1e16ad9..60138514ea86 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1019,7 +1019,6 @@ xfs_bmap_add_attrfork(
int size, /* space new attribute needs */
int rsvd) /* xact may use reserved blks */
{
- struct xfs_defer_ops dfops; /* freed extent records */
xfs_mount_t *mp; /* mount structure */
xfs_trans_t *tp; /* transaction pointer */
int blks; /* space reservation */
@@ -1038,7 +1037,6 @@ xfs_bmap_add_attrfork(
rsvd ? XFS_TRANS_RESERVE : 0, &tp);
if (error)
return error;
- xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL);
error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
@@ -1103,7 +1101,7 @@ xfs_bmap_add_attrfork(
if (logflags)
xfs_trans_log_inode(tp, ip, logflags);
if (error)
- goto bmap_cancel;
+ goto trans_cancel;
if (!xfs_sb_version_hasattr(&mp->m_sb) ||
(!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) {
bool log_sb = false;
@@ -1122,15 +1120,10 @@ xfs_bmap_add_attrfork(
xfs_log_sb(tp);
}
- error = xfs_defer_finish(&tp, &dfops);
- if (error)
- goto bmap_cancel;
error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error;
-bmap_cancel:
- xfs_defer_cancel(&dfops);
trans_cancel:
xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
@@ -5961,14 +5954,12 @@ xfs_bmap_split_extent(
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp;
- struct xfs_defer_ops dfops;
int error;
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write,
XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);
if (error)
return error;
- xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
@@ -5977,14 +5968,9 @@ xfs_bmap_split_extent(
if (error)
goto out;
- error = xfs_defer_finish(&tp, &dfops);
- if (error)
- goto out;
-
return xfs_trans_commit(tp);
out:
- xfs_defer_cancel(&dfops);
xfs_trans_cancel(tp);
return error;
}
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 2ecfb0518580..85e2d7c56c14 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1635,7 +1635,6 @@ xfs_refcount_recover_cow_leftovers(
struct list_head debris;
union xfs_btree_irec low;
union xfs_btree_irec high;
- struct xfs_defer_ops dfops;
xfs_fsblock_t fsb;
xfs_agblock_t agbno;
int error;
@@ -1691,22 +1690,17 @@ xfs_refcount_recover_cow_leftovers(
trace_xfs_refcount_recover_extent(mp, agno, &rr->rr_rrec);
/* Free the orphan record */
- xfs_defer_init(tp, &dfops);
agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
fsb = XFS_AGB_TO_FSB(mp, agno, agbno);
error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,
rr->rr_rrec.rc_blockcount);
if (error)
- goto out_defer;
+ goto out_trans;
/* Free the block. */
xfs_bmap_add_free(mp, tp->t_dfops, fsb,
rr->rr_rrec.rc_blockcount, NULL);
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto out_defer;
-
error = xfs_trans_commit(tp);
if (error)
goto out_free;
@@ -1716,8 +1710,6 @@ xfs_refcount_recover_cow_leftovers(
}
return error;
-out_defer:
- xfs_defer_cancel(tp->t_dfops);
out_trans:
xfs_trans_cancel(tp);
out_free:
diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
index d3055972d3a6..228821b2ebe0 100644
--- a/fs/xfs/xfs_attr_inactive.c
+++ b/fs/xfs/xfs_attr_inactive.c
@@ -382,7 +382,6 @@ xfs_attr_inactive(
{
struct xfs_trans *trans;
struct xfs_mount *mp;
- struct xfs_defer_ops dfops;
int lock_mode = XFS_ILOCK_SHARED;
int error = 0;
@@ -399,7 +398,6 @@ xfs_attr_inactive(
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_attrinval, 0, 0, 0, &trans);
if (error)
goto out_destroy_fork;
- xfs_defer_init(trans, &dfops);
lock_mode = XFS_ILOCK_EXCL;
xfs_ilock(dp, lock_mode);
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index ee9481b142f0..6b0f31402a81 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -792,7 +792,6 @@ xfs_free_eofblocks(
int nimaps;
struct xfs_bmbt_irec imap;
struct xfs_mount *mp = ip->i_mount;
- struct xfs_defer_ops dfops;
/*
* Figure out if there are any blocks beyond the end
@@ -832,7 +831,6 @@ xfs_free_eofblocks(
ASSERT(XFS_FORCED_SHUTDOWN(mp));
return error;
}
- xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0);
@@ -880,7 +878,6 @@ xfs_alloc_file_space(
int rt;
xfs_trans_t *tp;
xfs_bmbt_irec_t imaps[1], *imapp;
- struct xfs_defer_ops dfops;
uint qblocks, resblks, resrtextents;
int error;
@@ -973,7 +970,6 @@ xfs_alloc_file_space(
xfs_trans_ijoin(tp, ip, 0);
- xfs_defer_init(tp, &dfops);
error = xfs_bmapi_write(tp, ip, startoffset_fsb,
allocatesize_fsb, alloc_type, resblks,
imapp, &nimaps);
@@ -983,10 +979,6 @@ xfs_alloc_file_space(
/*
* Complete the transaction
*/
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto error0;
-
error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (error)
@@ -1005,8 +997,7 @@ xfs_alloc_file_space(
return error;
-error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */
- xfs_defer_cancel(&dfops);
+error0: /* unlock inode, unreserve quota blocks, cancel trans */
xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
error1: /* Just cancel transaction */
@@ -1024,7 +1015,6 @@ xfs_unmap_extent(
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp;
- struct xfs_defer_ops dfops;
uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
int error;
@@ -1042,23 +1032,17 @@ xfs_unmap_extent(
xfs_trans_ijoin(tp, ip, 0);
- xfs_defer_init(tp, &dfops);
error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
xfs_defer_ijoin(tp->t_dfops, ip);
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto out_bmap_cancel;
error = xfs_trans_commit(tp);
out_unlock:
xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error;
-out_bmap_cancel:
- xfs_defer_cancel(tp->t_dfops);
out_trans_cancel:
xfs_trans_cancel(tp);
goto out_unlock;
@@ -1310,7 +1294,6 @@ xfs_collapse_file_space(
struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp;
int error;
- struct xfs_defer_ops dfops;
xfs_fileoff_t next_fsb = XFS_B_TO_FSB(mp, offset + len);
xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len);
uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
@@ -1343,22 +1326,16 @@ xfs_collapse_file_space(
goto out_trans_cancel;
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
- xfs_defer_init(tp, &dfops);
error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
&done);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto out_bmap_cancel;
error = xfs_trans_commit(tp);
}
return error;
-out_bmap_cancel:
- xfs_defer_cancel(tp->t_dfops);
out_trans_cancel:
xfs_trans_cancel(tp);
return error;
@@ -1385,7 +1362,6 @@ xfs_insert_file_space(
struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp;
int error;
- struct xfs_defer_ops dfops;
xfs_fileoff_t stop_fsb = XFS_B_TO_FSB(mp, offset);
xfs_fileoff_t next_fsb = NULLFSBLOCK;
xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len);
@@ -1421,22 +1397,17 @@ xfs_insert_file_space(
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
- xfs_defer_init(tp, &dfops);
error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
&done, stop_fsb);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto out_bmap_cancel;
error = xfs_trans_commit(tp);
}
return error;
-out_bmap_cancel:
- xfs_defer_cancel(tp->t_dfops);
+out_trans_cancel:
xfs_trans_cancel(tp);
return error;
}
@@ -1607,7 +1578,7 @@ xfs_swap_extent_rmap(
/* Unmap the old blocks in the source file. */
while (tirec.br_blockcount) {
- xfs_defer_init(tp, tp->t_dfops);
+ ASSERT(tp->t_firstblock == NULLFSBLOCK);
trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec);
/* Read extent from the source file */
@@ -1841,7 +1812,6 @@ xfs_swap_extents(
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp;
- struct xfs_defer_ops dfops;
struct xfs_bstat *sbp = &sxp->sx_stat;
int src_log_flags, target_log_flags;
int error = 0;
@@ -1911,7 +1881,6 @@ xfs_swap_extents(
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp);
if (error)
goto out_unlock;
- xfs_defer_init(tp, &dfops);
/*
* Lock and join the inodes to the tansaction so that transaction commit
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index c53de34c9ae5..a57d5e8c3118 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -295,8 +295,6 @@ xfs_dquot_disk_alloc(
trace_xfs_dqalloc(dqp);
- xfs_defer_init(tp, tp->t_dfops);
-
xfs_ilock(quotip, XFS_ILOCK_EXCL);
if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
/*
@@ -538,7 +536,6 @@ xfs_qm_dqread_alloc(
struct xfs_buf **bpp)
{
struct xfs_trans *tp;
- struct xfs_defer_ops dfops;
struct xfs_buf *bp;
int error;
@@ -546,7 +543,6 @@ xfs_qm_dqread_alloc(
XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);
if (error)
goto err;
- xfs_defer_init(tp, &dfops);
error = xfs_dquot_disk_alloc(&tp, dqp, &bp);
if (error)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 7d7d7e95fa17..c47183a2f167 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1142,7 +1142,6 @@ xfs_create(
struct xfs_inode *ip = NULL;
struct xfs_trans *tp = NULL;
int error;
- struct xfs_defer_ops dfops;
bool unlock_dp_on_error = false;
prid_t prid;
struct xfs_dquot *udqp = NULL;
@@ -1194,8 +1193,6 @@ xfs_create(
xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
unlock_dp_on_error = true;
- xfs_defer_init(tp, &dfops);
-
/*
* Reserve disk quota and the inode.
*/
@@ -1236,11 +1233,11 @@ xfs_create(
if (is_dir) {
error = xfs_dir_init(tp, ip, dp);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
error = xfs_bumplink(tp, dp);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
}
/*
@@ -1258,10 +1255,6 @@ xfs_create(
*/
xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp);
- error = xfs_defer_finish(&tp, &dfops);
- if (error)
- goto out_bmap_cancel;
-
error = xfs_trans_commit(tp);
if (error)
goto out_release_inode;
@@ -1273,8 +1266,6 @@ xfs_create(
*ipp = ip;
return 0;
- out_bmap_cancel:
- xfs_defer_cancel(&dfops);
out_trans_cancel:
xfs_trans_cancel(tp);
out_release_inode:
@@ -1399,7 +1390,6 @@ xfs_link(
xfs_mount_t *mp = tdp->i_mount;
xfs_trans_t *tp;
int error;
- struct xfs_defer_ops dfops;
int resblks;
trace_xfs_link(tdp, target_name);
@@ -1448,8 +1438,6 @@ xfs_link(
goto error_return;
}
- xfs_defer_init(tp, &dfops);
-
/*
* Handle initial link state of O_TMPFILE inode
*/
@@ -1478,12 +1466,6 @@ xfs_link(
if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
xfs_trans_set_sync(tp);
- error = xfs_defer_finish(&tp, &dfops);
- if (error) {
- xfs_defer_cancel(&dfops);
- goto error_return;
- }
-
return xfs_trans_commit(tp);
error_return:
@@ -1719,7 +1701,6 @@ xfs_inactive_truncate(
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp;
- struct xfs_defer_ops dfops;
int error;
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
@@ -1727,8 +1708,6 @@ xfs_inactive_truncate(
ASSERT(XFS_FORCED_SHUTDOWN(mp));
return error;
}
- xfs_defer_init(tp, &dfops);
-
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0);
@@ -1769,7 +1748,6 @@ STATIC int
xfs_inactive_ifree(
struct xfs_inode *ip)
{
- struct xfs_defer_ops dfops;
struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp;
int error;
@@ -1806,7 +1784,6 @@ xfs_inactive_ifree(
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0);
- xfs_defer_init(tp, &dfops);
error = xfs_ifree(tp, ip);
if (error) {
/*
@@ -1833,12 +1810,6 @@ xfs_inactive_ifree(
* Just ignore errors at this point. There is nothing we can do except
* to try to keep going. Make sure it's not a silent error.
*/
- error = xfs_defer_finish(&tp, &dfops);
- if (error) {
- xfs_notice(mp, "%s: xfs_defer_finish returned error %d",
- __func__, error);
- xfs_defer_cancel(&dfops);
- }
error = xfs_trans_commit(tp);
if (error)
xfs_notice(mp, "%s: xfs_trans_commit returned error %d",
@@ -2569,7 +2540,6 @@ xfs_remove(
xfs_trans_t *tp = NULL;
int is_dir = S_ISDIR(VFS_I(ip)->i_mode);
int error = 0;
- struct xfs_defer_ops dfops;
uint resblks;
trace_xfs_remove(dp, name);
@@ -2649,11 +2619,10 @@ xfs_remove(
if (error)
goto out_trans_cancel;
- xfs_defer_init(tp, &dfops);
error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks);
if (error) {
ASSERT(error != -ENOENT);
- goto out_bmap_cancel;
+ goto out_trans_cancel;
}
/*
@@ -2664,10 +2633,6 @@ xfs_remove(
if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
xfs_trans_set_sync(tp);
- error = xfs_defer_finish(&tp, &dfops);
- if (error)
- goto out_bmap_cancel;
-
error = xfs_trans_commit(tp);
if (error)
goto std_return;
@@ -2677,8 +2642,6 @@ xfs_remove(
return 0;
- out_bmap_cancel:
- xfs_defer_cancel(&dfops);
out_trans_cancel:
xfs_trans_cancel(tp);
std_return:
@@ -2740,9 +2703,6 @@ static int
xfs_finish_rename(
struct xfs_trans *tp)
{
- struct xfs_defer_ops *dfops = tp->t_dfops;
- int error;
-
/*
* If this is a synchronous mount, make sure that the rename transaction
* goes to disk before returning to the user.
@@ -2750,13 +2710,6 @@ xfs_finish_rename(
if (tp->t_mountp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
xfs_trans_set_sync(tp);
- error = xfs_defer_finish(&tp, dfops);
- if (error) {
- xfs_defer_cancel(dfops);
- xfs_trans_cancel(tp);
- return error;
- }
-
return xfs_trans_commit(tp);
}
@@ -2869,7 +2822,6 @@ xfs_cross_rename(
return xfs_finish_rename(tp);
out_trans_abort:
- xfs_defer_cancel(tp->t_dfops);
xfs_trans_cancel(tp);
return error;
}
@@ -2924,7 +2876,6 @@ xfs_rename(
{
struct xfs_mount *mp = src_dp->i_mount;
struct xfs_trans *tp;
- struct xfs_defer_ops dfops;
struct xfs_inode *wip = NULL; /* whiteout inode */
struct xfs_inode *inodes[__XFS_SORT_INODES];
int num_inodes = __XFS_SORT_INODES;
@@ -3006,8 +2957,6 @@ xfs_rename(
goto out_trans_cancel;
}
- xfs_defer_init(tp, &dfops);
-
/* RENAME_EXCHANGE is unique from here on. */
if (flags & RENAME_EXCHANGE)
return xfs_cross_rename(tp, src_dp, src_name, src_ip,
@@ -3035,7 +2984,7 @@ xfs_rename(
error = xfs_dir_createname(tp, target_dp, target_name,
src_ip->i_ino, spaceres);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
xfs_trans_ichgtime(tp, target_dp,
XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
@@ -3043,7 +2992,7 @@ xfs_rename(
if (new_parent && src_is_directory) {
error = xfs_bumplink(tp, target_dp);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
}
} else { /* target_ip != NULL */
/*
@@ -3074,7 +3023,7 @@ xfs_rename(
error = xfs_dir_replace(tp, target_dp, target_name,
src_ip->i_ino, spaceres);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
xfs_trans_ichgtime(tp, target_dp,
XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
@@ -3085,7 +3034,7 @@ xfs_rename(
*/
error = xfs_droplink(tp, target_ip);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
if (src_is_directory) {
/*
@@ -3093,7 +3042,7 @@ xfs_rename(
*/
error = xfs_droplink(tp, target_ip);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
}
} /* target_ip != NULL */
@@ -3109,7 +3058,7 @@ xfs_rename(
target_dp->i_ino, spaceres);
ASSERT(error != -EEXIST);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
}
/*
@@ -3135,7 +3084,7 @@ xfs_rename(
*/
error = xfs_droplink(tp, src_dp);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
}
/*
@@ -3150,7 +3099,7 @@ xfs_rename(
error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
spaceres);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
/*
* For whiteouts, we need to bump the link count on the whiteout inode.
@@ -3164,10 +3113,10 @@ xfs_rename(
ASSERT(VFS_I(wip)->i_nlink == 0);
error = xfs_bumplink(tp, wip);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
error = xfs_iunlink_remove(tp, wip);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
xfs_trans_log_inode(tp, wip, XFS_ILOG_CORE);
/*
@@ -3188,8 +3137,6 @@ xfs_rename(
IRELE(wip);
return error;
-out_bmap_cancel:
- xfs_defer_cancel(&dfops);
out_trans_cancel:
xfs_trans_cancel(tp);
out_release_wip:
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 756694219f77..8e8ca9f03f0e 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -157,7 +157,6 @@ xfs_iomap_write_direct(
int quota_flag;
int rt;
xfs_trans_t *tp;
- struct xfs_defer_ops dfops;
uint qblocks, resblks, resrtextents;
int error;
int lockmode;
@@ -253,20 +252,15 @@ xfs_iomap_write_direct(
* From this point onwards we overwrite the imap pointer that the
* caller gave to us.
*/
- xfs_defer_init(tp, &dfops);
nimaps = 1;
error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
bmapi_flags, resblks, imap, &nimaps);
if (error)
- goto out_bmap_cancel;
+ goto out_res_cancel;
/*
* Complete the transaction
*/
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto out_bmap_cancel;
-
error = xfs_trans_commit(tp);
if (error)
goto out_unlock;
@@ -286,8 +280,7 @@ xfs_iomap_write_direct(
xfs_iunlock(ip, lockmode);
return error;
-out_bmap_cancel:
- xfs_defer_cancel(tp->t_dfops);
+out_res_cancel:
xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
out_trans_cancel:
xfs_trans_cancel(tp);
@@ -663,7 +656,6 @@ xfs_iomap_write_allocate(
xfs_mount_t *mp = ip->i_mount;
xfs_fileoff_t offset_fsb, last_block;
xfs_fileoff_t end_fsb, map_start_fsb;
- struct xfs_defer_ops dfops;
xfs_filblks_t count_fsb;
xfs_trans_t *tp;
int nimaps;
@@ -713,8 +705,6 @@ xfs_iomap_write_allocate(
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0);
- xfs_defer_init(tp, &dfops);
-
/*
* it is possible that the extents have changed since
* we did the read call as we dropped the ilock for a
@@ -772,10 +762,6 @@ xfs_iomap_write_allocate(
if (error)
goto trans_cancel;
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto trans_cancel;
-
error = xfs_trans_commit(tp);
if (error)
goto error0;
@@ -806,7 +792,6 @@ xfs_iomap_write_allocate(
}
trans_cancel:
- xfs_defer_cancel(tp->t_dfops);
xfs_trans_cancel(tp);
error0:
xfs_iunlock(ip, XFS_ILOCK_EXCL);
@@ -827,7 +812,6 @@ xfs_iomap_write_unwritten(
int nimaps;
xfs_trans_t *tp;
xfs_bmbt_irec_t imap;
- struct xfs_defer_ops dfops;
struct inode *inode = VFS_I(ip);
xfs_fsize_t i_size;
uint resblks;
@@ -872,7 +856,6 @@ xfs_iomap_write_unwritten(
/*
* Modify the unwritten extent state of the buffer.
*/
- xfs_defer_init(tp, &dfops);
nimaps = 1;
error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
XFS_BMAPI_CONVERT, resblks, &imap,
@@ -896,10 +879,6 @@ xfs_iomap_write_unwritten(
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
}
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto error_on_bmapi_transaction;
-
error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (error)
@@ -923,7 +902,6 @@ xfs_iomap_write_unwritten(
return 0;
error_on_bmapi_transaction:
- xfs_defer_cancel(tp->t_dfops);
xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 704b57a8b99e..2eac22bfad6a 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -813,7 +813,6 @@ xfs_setattr_size(
struct inode *inode = VFS_I(ip);
xfs_off_t oldsize, newsize;
struct xfs_trans *tp;
- struct xfs_defer_ops dfops;
int error;
uint lock_flags = 0;
bool did_zeroing = false;
@@ -917,7 +916,6 @@ xfs_setattr_size(
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
if (error)
return error;
- xfs_defer_init(tp, &dfops);
lock_flags |= XFS_ILOCK_EXCL;
xfs_ilock(ip, XFS_ILOCK_EXCL);
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 958e9b96dc6a..265e1f561157 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -4857,15 +4857,7 @@ xlog_finish_defer_ops(
/* transfer all collected dfops to this transaction */
xfs_defer_move(tp->t_dfops, dfops);
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto out_cancel;
-
return xfs_trans_commit(tp);
-
-out_cancel:
- xfs_trans_cancel(tp);
- return error;
}
/*
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index df0783303887..c07c5a39d516 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -214,7 +214,6 @@ xfs_qm_scall_trunc_qfile(
{
struct xfs_inode *ip;
struct xfs_trans *tp;
- struct xfs_defer_ops dfops;
int error;
if (ino == NULLFSINO)
@@ -231,7 +230,6 @@ xfs_qm_scall_trunc_qfile(
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
goto out_put;
}
- xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0);
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index c3f2a0d3e6f5..865ba615dd76 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -364,7 +364,6 @@ xfs_reflink_allocate_cow(
xfs_fileoff_t offset_fsb = imap->br_startoff;
xfs_filblks_t count_fsb = imap->br_blockcount;
struct xfs_bmbt_irec got;
- struct xfs_defer_ops dfops;
struct xfs_trans *tp = NULL;
int nimaps, error = 0;
bool trimmed;
@@ -424,7 +423,6 @@ xfs_reflink_allocate_cow(
xfs_trans_ijoin(tp, ip, 0);
- xfs_defer_init(tp, &dfops);
nimaps = 1;
/* Allocate the entire reservation as unwritten blocks. */
@@ -432,15 +430,11 @@ xfs_reflink_allocate_cow(
XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC,
resblks, imap, &nimaps);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
xfs_inode_set_cowblocks_tag(ip);
/* Finish up. */
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto out_bmap_cancel;
-
error = xfs_trans_commit(tp);
if (error)
return error;
@@ -453,8 +447,7 @@ xfs_reflink_allocate_cow(
return -ENOSPC;
convert:
return xfs_reflink_convert_cow_extent(ip, imap, offset_fsb, count_fsb);
-out_bmap_cancel:
- xfs_defer_cancel(tp->t_dfops);
+out_trans_cancel:
xfs_trans_unreserve_quota_nblks(tp, ip, (long)resblks, 0,
XFS_QMOPT_RES_REGBLKS);
out:
@@ -624,7 +617,6 @@ xfs_reflink_end_cow(
struct xfs_trans *tp;
xfs_fileoff_t offset_fsb;
xfs_fileoff_t end_fsb;
- struct xfs_defer_ops dfops;
int error;
unsigned int resblks;
xfs_filblks_t rlen;
@@ -691,11 +683,11 @@ xfs_reflink_end_cow(
goto prev_extent;
/* Unmap the old blocks in the data fork. */
- xfs_defer_init(tp, &dfops);
+ ASSERT(tp->t_dfops && tp->t_firstblock == NULLFSBLOCK);
rlen = del.br_blockcount;
error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1);
if (error)
- goto out_defer;
+ goto out_cancel;
/* Trim the extent to whatever got unmapped. */
if (rlen) {
@@ -708,13 +700,13 @@ xfs_reflink_end_cow(
error = xfs_refcount_free_cow_extent(tp->t_mountp, tp->t_dfops,
del.br_startblock, del.br_blockcount);
if (error)
- goto out_defer;
+ goto out_cancel;
/* Map the new blocks into the data fork. */
error = xfs_bmap_map_extent(tp->t_mountp, tp->t_dfops, ip,
&del);
if (error)
- goto out_defer;
+ goto out_cancel;
/* Charge this new data fork mapping to the on-disk quota. */
xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_DELBCOUNT,
@@ -726,7 +718,7 @@ xfs_reflink_end_cow(
xfs_defer_ijoin(tp->t_dfops, ip);
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
- goto out_defer;
+ goto out_cancel;
if (!xfs_iext_get_extent(ifp, &icur, &got))
break;
continue;
@@ -741,8 +733,6 @@ xfs_reflink_end_cow(
goto out;
return 0;
-out_defer:
- xfs_defer_cancel(tp->t_dfops);
out_cancel:
xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
@@ -998,7 +988,6 @@ xfs_reflink_remap_extent(
bool real_extent = xfs_bmap_is_real_extent(irec);
struct xfs_trans *tp;
unsigned int resblks;
- struct xfs_defer_ops dfops;
struct xfs_bmbt_irec uirec;
xfs_filblks_t rlen;
xfs_filblks_t unmap_len;
@@ -1039,10 +1028,10 @@ xfs_reflink_remap_extent(
/* Unmap the old blocks in the data fork. */
rlen = unmap_len;
while (rlen) {
- xfs_defer_init(tp, &dfops);
+ ASSERT(tp->t_dfops && tp->t_firstblock == NULLFSBLOCK);
error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1);
if (error)
- goto out_defer;
+ goto out_cancel;
/*
* Trim the extent to whatever got unmapped.
@@ -1063,12 +1052,12 @@ xfs_reflink_remap_extent(
/* Update the refcount tree */
error = xfs_refcount_increase_extent(mp, tp->t_dfops, &uirec);
if (error)
- goto out_defer;
+ goto out_cancel;
/* Map the new blocks into the data fork. */
error = xfs_bmap_map_extent(mp, tp->t_dfops, ip, &uirec);
if (error)
- goto out_defer;
+ goto out_cancel;
/* Update quota accounting. */
xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT,
@@ -1090,7 +1079,7 @@ xfs_reflink_remap_extent(
xfs_defer_ijoin(tp->t_dfops, ip);
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
- goto out_defer;
+ goto out_cancel;
}
error = xfs_trans_commit(tp);
@@ -1099,8 +1088,6 @@ xfs_reflink_remap_extent(
goto out;
return 0;
-out_defer:
- xfs_defer_cancel(tp->t_dfops);
out_cancel:
xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index bc471d42a968..86d7d2f76226 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -761,7 +761,6 @@ xfs_growfs_rt_alloc(
struct xfs_buf *bp; /* temporary buffer for zeroing */
xfs_daddr_t d; /* disk block address */
int error; /* error return value */
- struct xfs_defer_ops dfops; /* list of freed blocks */
xfs_fsblock_t fsbno; /* filesystem block for bno */
struct xfs_bmbt_irec map; /* block map output */
int nmap; /* number of block maps */
@@ -786,7 +785,6 @@ xfs_growfs_rt_alloc(
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
- xfs_defer_init(tp, &dfops);
/*
* Allocate blocks to the bitmap file.
*/
@@ -797,13 +795,10 @@ xfs_growfs_rt_alloc(
if (!error && nmap < 1)
error = -ENOSPC;
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
/*
* Free any blocks freed up in the transaction, then commit.
*/
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto out_bmap_cancel;
error = xfs_trans_commit(tp);
if (error)
return error;
@@ -853,8 +848,6 @@ xfs_growfs_rt_alloc(
return 0;
-out_bmap_cancel:
- xfs_defer_cancel(tp->t_dfops);
out_trans_cancel:
xfs_trans_cancel(tp);
return error;
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index d1ab0afa2723..ce801aedbcdc 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -163,7 +163,6 @@ xfs_symlink(
struct xfs_inode *ip = NULL;
int error = 0;
int pathlen;
- struct xfs_defer_ops dfops;
bool unlock_dp_on_error = false;
xfs_fileoff_t first_fsb;
xfs_filblks_t fs_blocks;
@@ -241,12 +240,6 @@ xfs_symlink(
if (error)
goto out_trans_cancel;
- /*
- * Initialize the bmap freelist prior to calling either
- * bmapi or the directory create code.
- */
- xfs_defer_init(tp, &dfops);
-
/*
* Allocate an inode for the symlink.
*/
@@ -290,7 +283,7 @@ xfs_symlink(
error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks,
XFS_BMAPI_METADATA, resblks, mval, &nmaps);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
if (resblks)
resblks -= fs_blocks;
@@ -308,7 +301,7 @@ xfs_symlink(
BTOBB(byte_cnt), 0);
if (!bp) {
error = -ENOMEM;
- goto out_bmap_cancel;
+ goto out_trans_cancel;
}
bp->b_ops = &xfs_symlink_buf_ops;
@@ -337,7 +330,7 @@ xfs_symlink(
*/
error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks);
if (error)
- goto out_bmap_cancel;
+ goto out_trans_cancel;
xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
@@ -350,10 +343,6 @@ xfs_symlink(
xfs_trans_set_sync(tp);
}
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto out_bmap_cancel;
-
error = xfs_trans_commit(tp);
if (error)
goto out_release_inode;
@@ -365,8 +354,6 @@ xfs_symlink(
*ipp = ip;
return 0;
-out_bmap_cancel:
- xfs_defer_cancel(tp->t_dfops);
out_trans_cancel:
xfs_trans_cancel(tp);
out_release_inode:
@@ -399,7 +386,6 @@ xfs_inactive_symlink_rmt(
xfs_buf_t *bp;
int done;
int error;
- struct xfs_defer_ops dfops;
int i;
xfs_mount_t *mp;
xfs_bmbt_irec_t mval[XFS_SYMLINK_MAPS];
@@ -438,7 +424,6 @@ xfs_inactive_symlink_rmt(
* Find the block(s) so we can inval and unmap them.
*/
done = 0;
- xfs_defer_init(tp, &dfops);
nmaps = ARRAY_SIZE(mval);
error = xfs_bmapi_read(ip, 0, xfs_symlink_blocks(mp, size),
mval, &nmaps, 0);
@@ -453,7 +438,7 @@ xfs_inactive_symlink_rmt(
XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0);
if (!bp) {
error = -ENOMEM;
- goto error_bmap_cancel;
+ goto error_trans_cancel;
}
xfs_trans_binval(tp, bp);
}
@@ -462,19 +447,14 @@ xfs_inactive_symlink_rmt(
*/
error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &done);
if (error)
- goto error_bmap_cancel;
+ goto error_trans_cancel;
ASSERT(done);
- /*
- * Commit the first transaction. This logs the EFI and the inode.
- */
- xfs_defer_ijoin(tp->t_dfops, ip);
- error = xfs_defer_finish(&tp, tp->t_dfops);
- if (error)
- goto error_bmap_cancel;
/*
- * Commit the transaction containing extent freeing and EFDs.
+ * Commit the transaction. This first logs the EFI and the inode, then
+ * rolls and commits the transaction that frees the extents.
*/
+ xfs_defer_ijoin(tp->t_dfops, ip);
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
error = xfs_trans_commit(tp);
if (error) {
@@ -492,8 +472,6 @@ xfs_inactive_symlink_rmt(
xfs_iunlock(ip, XFS_ILOCK_EXCL);
return 0;
-error_bmap_cancel:
- xfs_defer_cancel(tp->t_dfops);
error_trans_cancel:
xfs_trans_cancel(tp);
error_unlock:
--
2.17.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.