xfs error : “mount: Structure needs cleaning”

When we want to mount a xfs partition, sometimes we get “mount: Structure needs cleaning” error, and we can not mount a server.

# mount /dev/md2 /data
mount: Structure needs cleaning

Sometime using this command, we will get return

xfs_repair -n /dev/md2

But when we try to mount, we still get this error,

# xfs_check /dev/md2
ERROR: The filesystem has valuable metadata changes in a log which needs to
be replayed. Mount the filesystem to replay the log, and unmount it before
re-running xfs_check. If you are unable to mount the filesystem, then use
the xfs_repair -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption — please attempt a mount
of the filesystem before doing this.

We can repair xfs device using this command,

xfs_repair -L /dev/md2

After that, try to mount using this command,

# mount /dev/sdb1 /disk2

Read File in Diretory using Python Programming

You can list all files in the current directory using:

import os
for filename in os.listdir(os.getcwd()):
   # do your stuff

Or you can list only some files, depending on the file pattern using the glob module:

import glob
for filename in glob.glob('*.txt'):
   # do your stuff

It doesn’t have to be the current directory you can list them in any path you want:

path = '/some/path/to/file'

for filename in os.listdir(path):
    # do your stuff

for filename in glob.glob(os.path.join(path, '*.txt')):
    # do your stuff

Or you can even use the pipe as you specified using fileinput

import fileinput
for line in fileinput.input():
    # do your stuff