8 Star 0 Fork 5

src-anolis-os/glusterfs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0348-glusterfind-Fix-py2-py3-issues.patch 4.89 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 16:09 . update to glusterfs-6.0-49.1.el8.src.rpm
From 1ca8a545833e0a6e674984245338b8675ddc58bc Mon Sep 17 00:00:00 2001
From: Kotresh HR <[email protected]>
Date: Fri, 10 Jan 2020 16:48:14 +0530
Subject: [PATCH 348/349] glusterfind: Fix py2/py3 issues
1. In dictionary values(), returns list in py2 and not in py3.
So explicitly convert it into list.
2. xattr module returns values in bytes. So explicitly convert
them to str to work both with py2 and py3
Backport of:
> Patch: https://review.gluster.org/23993
> fixes: bz#1789439
> Change-Id: I27a639cda4f7a4ece9744a97c3d16e247906bd94
> Signed-off-by: Kotresh HR <[email protected]>
BUG: 1789447
Change-Id: I27a639cda4f7a4ece9744a97c3d16e247906bd94
Signed-off-by: Kotresh HR <[email protected]>
Reviewed-on: https://code.engineering.redhat.com/gerrit/189215
Reviewed-by: Shwetha Acharya <[email protected]>
Tested-by: RHGS Build Bot <[email protected]>
Reviewed-by: Hari Gowtham Gopal <[email protected]>
Reviewed-by: Sunny Kumar <[email protected]>
---
tools/glusterfind/src/changelog.py | 14 +++++++++-----
tools/glusterfind/src/main.py | 8 ++++----
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py
index d8f97e0..d972fb5 100644
--- a/tools/glusterfind/src/changelog.py
+++ b/tools/glusterfind/src/changelog.py
@@ -14,6 +14,7 @@ import sys
import time
import xattr
import logging
+from gfind_py2py3 import bytearray_to_str
from argparse import ArgumentParser, RawDescriptionHelpFormatter
import hashlib
try:
@@ -105,9 +106,10 @@ def populate_pgfid_and_inodegfid(brick, changelog_data):
changelog_data.inodegfid_add(os.stat(p).st_ino, gfid)
file_xattrs = xattr.list(p)
for x in file_xattrs:
- if x.startswith("trusted.pgfid."):
+ x_str = bytearray_to_str(x)
+ if x_str.startswith("trusted.pgfid."):
# PGFID in pgfid table
- changelog_data.pgfid_add(x.split(".")[-1])
+ changelog_data.pgfid_add(x_str.split(".")[-1])
except (IOError, OSError):
# All OS Errors ignored, since failures will be logged
# in End. All GFIDs present in gfidpath table
@@ -122,10 +124,12 @@ def enum_hard_links_using_gfid2path(brick, gfid, args):
try:
file_xattrs = xattr.list(p)
for x in file_xattrs:
- if x.startswith("trusted.gfid2path."):
+ x_str = bytearray_to_str(x)
+ if x_str.startswith("trusted.gfid2path."):
# get the value for the xattr i.e. <PGFID>/<BN>
- v = xattr.getxattr(p, x)
- pgfid, bn = v.split(os.sep)
+ v = xattr.getxattr(p, x_str)
+ v_str = bytearray_to_str(v)
+ pgfid, bn = v_str.split(os.sep)
try:
path = symlink_gfid_to_path(brick, pgfid)
fullpath = os.path.join(path, bn)
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
index fefe4a3..dfc9d07 100644
--- a/tools/glusterfind/src/main.py
+++ b/tools/glusterfind/src/main.py
@@ -633,7 +633,7 @@ def mode_query(session_dir, args):
# Merger
if args.full:
if len(g_pid_nodefile_map) > 0:
- cmd = ["sort", "-u"] + g_pid_nodefile_map.values() + \
+ cmd = ["sort", "-u"] + list(g_pid_nodefile_map.values()) + \
["-o", args.outfile]
execute(cmd,
exit_msg="Failed to merge output files "
@@ -645,7 +645,7 @@ def mode_query(session_dir, args):
# Read each Changelogs db and generate finaldb
create_file(args.outfile, exit_on_err=True, logger=logger)
outfilemerger = OutputMerger(args.outfile + ".db",
- g_pid_nodefile_map.values())
+ list(g_pid_nodefile_map.values()))
write_output(args.outfile, outfilemerger, args.field_separator)
try:
@@ -702,7 +702,7 @@ def mode_pre(session_dir, args):
# Merger
if args.full:
if len(g_pid_nodefile_map) > 0:
- cmd = ["sort", "-u"] + g_pid_nodefile_map.values() + \
+ cmd = ["sort", "-u"] + list(g_pid_nodefile_map.values()) + \
["-o", args.outfile]
execute(cmd,
exit_msg="Failed to merge output files "
@@ -714,7 +714,7 @@ def mode_pre(session_dir, args):
# Read each Changelogs db and generate finaldb
create_file(args.outfile, exit_on_err=True, logger=logger)
outfilemerger = OutputMerger(args.outfile + ".db",
- g_pid_nodefile_map.values())
+ list(g_pid_nodefile_map.values()))
write_output(args.outfile, outfilemerger, args.field_separator)
try:
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/glusterfs.git
[email protected]:src-anolis-os/glusterfs.git
src-anolis-os
glusterfs
glusterfs
a8

搜索帮助